今天在使用idea開發一個web項目的時候,頁面404,並顯示路徑$%7BpageContext.request.contextPath%7D,我在jsp頁面中明明使用的是${pageContext.request.contextPath},查找之后發現是在建項目的時候web-app版本問題,我的web.xml中頭文件的配置是:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
將其改為:
<?xml version="1.0" encoding="UTF-8"?> <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">