版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38373006/article/details/88292259
新接的十分古老的老项目,在使用chrome浏览器时正常,但在ie浏览器下会导致404。
排查过程:点击按钮,js内使用的为location = "./sms/aa/bbb/ccc.do(后台接口地址)";
在chrome下的url地址正常,但在ie浏览器下url地址会相较chrome多出/sms的链接地址。从而导致找不到后台接口,从而404。
解决方法:
1,获取项目绝对链接地址:
jsp内方法:(若其他,通过接口获取或直接使用js的方法即可)
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
2,在js使用location跳转时:
location = "<%=basePath%>bbb/aaa.do?method=findSmsSql&midType="+titleName2+"&mobile="+mobile;
即可解决!