根据请求地址获取域名

如果有域名就会获取域名,如果没有就获取IP+端口

使用request来获取:

StringBuffer url = request.getRequestURL();
String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append(request.getServletContext().getContextPath()).append("/").toString();

猜你喜欢

转载自a511480568.iteye.com/blog/2268714