由于使用的是archetype-webapp生成的web工程,默认创建的web版本为2.3
导致在jsp中获取使用pageContext获取项目路径时被错误解析
解决方法:
将版本更改为2.3以上版本,或复制下面代码到web.xml文件中,改为4.0版本
<?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">
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
或者通过project Structure来更改版本,记得备份web.xml的配置信息