struts2学习中遇到的坑之${pageContext.request.contextPath}错误

来源:互联网 发布:淘宝手机店铺装修尺寸 编辑:程序博客网 时间:2024/06/16 04:55

错误提示
Stacktrace:] with root cause
javax.el.PropertyNotFoundException: Property ‘ContextPath’ not found on type org.apache.struts2.dispatcher.StrutsRequestWrapper
这里写图片描述
很明显,路径写错了
${pageContext.request.contextPath}
是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> 。
也就是取出部署的应用程序名或者是当前的项目名称
如果我的项目名称是demo在浏览器中输入为http://localhost:8080/demo/index.jsp ${pageContext.request.contextPath}或<%=request.getContextPath()%>取出来的就是/demo,而”/”代表的含义就是http://localhost:8080
故有时候项目中这样写${pageContext.request.contextPath}/index.jsp

原创粉丝点击