从a页面跳转到b页面时候,
b页面对应的js相关代码
(注释:这里待会会涉及上一个页面的链接: 假设上一个页面***a***的地址为:localhost:8080/test/save)
b页面的相关js
var url = ${relurl};
//后台传过来的链接relurl 后台获取的是类型ip
// eg:localhost等
//previewUrl =localhost:8080/test/test.jsp是文件访问路径
var allPath = url +':8012/onlinePreview?url='+encodeURIComponent(previewUrl);
window.open(allPath);
正常情况下打开的链接的地址应该是类似这种情况
localhost:8082/onlinePreview?url=localhost:8080/test/test.jsp;
结果打开后的链接变成了:
localhost:8080/test/:8082/onlinePreview?url=localhost:8080/test/test.jsp;
(在上一个页面的链接进行改变)
因为我那个页面的特殊性,就不讲为啥在第一时间找不出是后台传过来的relurl问题了,
(1)首先我就把他定位在了window.open()这个方法上,查到了需要在地址前面加上http://;
即:http://localhost:8080/test/:8082/onlinePreview?url=localhost:8080/test/test.jsp;
但我的情况不是这种类型,所以不能解决
参考链接:https://blog.csdn.net/The_Thinnest/article/details/78804379?utm_source=blogxgwz9
(2)后来经过一番辗转,重新定位到后台传值的relurl上
发现当url为空的时候,
本来应该allPath =:8082/onlinePreview?url=localhost:8080/test/test.jsp;
但却变成了localhost:8080/test/:8082/onlinePreview?url=localhost:8080/test/test.jsp
猜想:当打开地址的时候,没有识别到ip开头时候,会默认取上一级的路径进行拼接