关于发布项目后进行域名访问,地址栏变为ip地址

时间:2021-10-15 16:56:56
在jsp页面是使用<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>">
代表url使用的是绝对地址,在配置域名的时候,会导致跳转后域名变成ip地址。