$%7BpageContext.request.contextPath%7D
p
a
g
e
C
o
n
t
e
x
t
.
r
e
q
u
e
s
t
.
c
o
n
t
e
x
t
P
a
t
h
被
解
析
成
{pageContext.request.contextPath}被解析成
pageContext.request.contextPath被解析成%7BpageContext.request.contextPath%7D
Java项目中,当你在jsp中使用${pageContext.request.contextPath}来获取相对路径
但是发布项目后,访问页面时, p a g e C o n t e x t . r e q u e s t . c o n t e x t P a t h 被 解 析 成 {pageContext.request.contextPath}被解析成 pageContext.request.contextPath被解析成%7BpageContext.request.contextPath%7D
解决方案:查看web.xml中头文件web-app的版本,如果低于2.4,修改web-app的版本即可正常获取相对路径,页面正常显示显示。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>website name</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>