Maven項目配置EL表達式原樣輸出解決方法

  • Maven搭建的web項目 在jsp頁面使用EL表達式時,EL表達式內容原樣輸出致使異常問題。pom.xml文件須要添加如下jar包引用
 1         <dependency>
 2             <groupId>javax.servlet</groupId>
 3             <artifactId>jstl</artifactId>
 4             <version>1.2</version>
 5         </dependency>
 6       
 7         <dependency>
 8             <groupId>taglibs</groupId>
 9             <artifactId>standard</artifactId>
10             <version>1.1.2</version>
11         </dependency>
  • maven生成的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" >
 
<web-app>
  • 須要修改web.xml。緣由是由於maven生成的web.xml版本過低了,2.5以前web.xml文件中的頭定義中,EL表達式默認是忽略不解析的,故須要顯示聲明解析el表達式
1 <web-app version="3.0"
2  xmlns="http://java.sun.com/xml/ns/javaee"
3  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 5  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  • 另外能夠在使用EL表達式的jsp頁面聲明 
1 <%@ page isELIgnored="false" %>
相關文章
相關標籤/搜索