How to get request URI without context path?

前端 未结 7 1056
时光说笑
时光说笑 2020-12-22 15:21

The Method request.getRequestURI() returns URI with context path.

For example, if the base URL of an application is http://localhost:8080/myapp/ (i.e.

7条回答
  •  粉色の甜心
    2020-12-22 16:02

    May be you can just use the split method to eliminate the '/myapp' for example:

    string[] uris=request.getRequestURI().split("/");
    string uri="/"+uri[1]+"/"+uris[2];
    

提交回复
热议问题