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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a974986042/article/details/73954859

错误提示
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

猜你喜欢

转载自blog.csdn.net/a974986042/article/details/73954859