所以所有的href链接都自动加上了工程名的链接http://localhost:8080/[工程名] 现在,页面有两个字“百度”需要加上链接“www.baidu.com”,">
当前位置:Gxlcms > html代码 > 实现jsp绝对跳转,前面不加工程名。如直接跳转到百度。_html/css_WEB-ITnose

实现jsp绝对跳转,前面不加工程名。如直接跳转到百度。_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:2人阅读

现在的jsp页面为了跳转方便,前面加了
<%	String path = request.getContextPath();	// 获得项目完全路径(假设你的项目叫MyApp,那么获得到的地址就是 http://localhost:8080/MyApp/):	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>  

所以所有的href链接都自动加上了工程名的链接http://localhost:8080/[工程名]

现在,页面有两个字“百度”需要加上链接“www.baidu.com”,所以在点击链接时就变成了
“http://localhost:8080/[工程名]/www.baidu.com”
这种问题怎么解决?


回复讨论(解决方案)

http://www.baidu.com
这样呢?

前面直接加上http://
或者使用window.open("url");这种方式

人气教程排行