spring mvc中获取请求URL

String baseUrl=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort+request.getContextPath()+"/";

得到形如http://www.baidu.com:8080/xxx

从HttpServletRequest获取:
request.getRemoteAddr()获取ip
request.getRemotePort()获取端口号
request.getServletPath()获取请求地址
posted @ 2018-03-08 13:34  Franson  阅读(8079)  评论(0编辑  收藏  举报