在JSP2.0中,增長了EL語言,能夠經過EL語言,實現獲取數據,進一步將script代碼從JSP頁面中分離出來.EL語言給你們帶來了方便,但有時,也會遇到EL表達式不能顯示的狀況,下面,我將列舉幾種EL表達式不java
能顯示的狀況及解決方案:
1.WEB-INF/web.xml,web應用的部署描述文件引用的是servlet規範的2.3版本或更早的版本(即jsp1.2或更早),則jsp2.0表達式語言自動在web應用中停用。2.3版本xml指令和文檔類型定義以下:web
<!-- 2.3版本即jsp1.2 jsp2.0表達式語言自動停用 --> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
若是是2.4版本,則爲:app
<!-- 2.4版本即jsp2.0 表達式語言可用 --> <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
2.web.xml中,是否停用了jsp表達式語言jsp
<jsp-config> <jsp-property-group> <url-pattern>/legacy/*.jsp</url-pattern> <el-ignored>true</el-ignored> </jsp-property-group> </jsp-config>
這種狀況的解決方法就是把<el-ignored>true</el-ignored>改成<el-ignored>false</el-ignored>url
3.頁面停用jsp表達式語言spa
<%@ page isELEnabled ="false"%>
解決方法:改成<%@ page isELEnabled ="true"%>code