jsp中连接跳转丢失项目名

jsp为:

  <p><a href="web/wechat/view/index.html">index</a></p>

点击index后,跳转地址为

 http://localhost:8080/web/wechat/view/index.html

少了项目名ddh,正确的如下:

 http://localhost:8080/ddh/web/wechat/view/index.html

修改application context,也无效

建议所有的链接请求都使用绝对路径,你可以写一个全局拦截器,把request.getContextPath() 存到request里面全局调用

已解决,更换或修改tomcat。

jsp中得到ContextPath的两种方法

1.script
<%=request.getContextPath()%>

2.el
${pageContext.request.contextPath}

在href连接中 加入ddh就可以解决该问题

jsp中得到ContextPath的两种方法

1.script
<%=request.getContextPath()%>

2.el
${pageContext.request.contextPath}