${pageContext.request.contextPath}失效的原因可能有两种: 1. jsp默认<%@ page isELIgnored="true"%>,只要在有EL表达式的jsp页面限制<%@ page isELIgnored="false"%>。 就可以正确解释EL表达式了。 2. 说是web.xml 里面的web-app元素声明的版本号太低,即2.4以上才能用。 建议换种方式: <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> 使用 <%=basePath %> 替代 ${pageContext.request.contextPath}
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
67,514
社区成员
225,878
社区内容
加载中
试试用AI创作助手写篇文章吧