项目中使用了springMVC
问题描述:
DownloadController的RequestMapping值为"download/downloadinfo"
页面<base href="<%=basePath%>"/>
其中basePath为
<%
String path = request.getContextPath();
if (!path.endsWith("/")) {
path = path + "/";
}
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
String uiPath = basePath + "resources/ui/";
%>
使用 href="/download/downloadinfo.htm"方式访问正确
浏览器中的URL为:
http://122.114.4.136/download...
使用 href="download/downloadinfo.htm"方式访问出错
浏览器中的URL为:
http://122.114.4.136/home/dow...
错误原因是浏览器自动在URL中加入了/home,出现了404错误
出现错误浏览器有关,chrome和Firefox不会出错,Edge和360会报错,还有项目在本地运行用
360访问不会出现错误,运行在外网,在内网却会报错?
问题:为什么浏览器会在URL中自动加入/home?
浏览器不会自动加什么东西,肯定是你的配置上填上了,你先打个断点,看看<%=basePath%>是什么,
可能是你的项目部署的地方加上了home