/**
* 获得当前访问的URL路径
* @param request
* @return
*/
public static String getLocation(HttpServletRequest request) {
UrlPathHelper helper = new UrlPathHelper();
StringBuffer buff = request.getRequestURL();
String uri = request.getRequestURI();
String origUri = helper.getOriginatingRequestUri(request);
buff.replace(buff.length() - uri.length(), buff.length(), origUri);
String queryString = helper.getOriginatingQueryString(request);
if (queryString != null) {
buff.append("?").append(queryString);
}
try {
return new String(buff.toString().getBytes(), "iso-8859-1");
} catch (UnsupportedEncodingException e) {
return buff.toString();
}
}
js获取方式:https://www.cnblogs.com/pxblog/p/13737882.html
-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------
(蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)