使用${pageContext.request.contextPath} 出现错误(转载)

IDEA开发web项目 使用${pageContext.request.contextPath} 出现问题

今天在写web项目时,在前端页面中使用${pageContext.request.contextPath}获取路径时出现%7BpageContext.request.contextPath%7D

使用${pageContext.request.contextPath} 如下:
在这里插入图片描述

错误如下:
在这里插入图片描述

最后发现是web.xml的问题 我的xml是这样的:
在这里插入图片描述
改成这样就好了:
在这里插入图片描述

最后附上代码:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <display-name>Archetype Created Web Application</display-name>
</web-app>

转载于:https://www.cnblogs.com/King-boy/p/11488093.html

posted @ 2020-10-09 16:36  tyroguo  阅读(507)  评论(1)    收藏  举报