今天在IDEA建立web項目以後發現沒法使用EL和JSTL,html
1、若是JSP中沒法自動提示EL表達式,好比${pageContext.request.contextPath},可在pom.xml的<dependencies>
標籤中插入如下代碼java
<dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency>
下面是EL和JSTL的座標,不用pom.xml中設置,由上面的依賴傳遞:web
<!--EL和JSTL--> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency>
2、若是沒法使用EL表達式
方法1:更改web.xml的web-app標籤中的命名空間,可改爲以下
api
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> </web-app>
方法2:在jsp頁面開頭添加<%@ page isELIgnored="false"%>
app