el 表達式沒法解析了,
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
這個能解析:
<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">
google結果:
http://hi.baidu.com/alwaysbeeline/blog/item/14384d90e7d83989a877a47d.html
http://blog.csdn.net/yriio/archive/2008/05/21/2467256.aspx
今天也碰到el表達式無法解析的事情,於是在網上查詢了下,盜取了一篇,說的挺詳細的!
web.xml聲明部分一般分爲如下版本的xsd,
web-app_2_2.xsd
web-app_2_3.xsd
web-app_2_4.xsd
web-app_2_5.xsd
更詳細的列出各版本web.xml聲明部分吧,如下:
web-app_2_2.xsd
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/dtd/web-app_2_2.dtd">
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/dtd/web-app_2_2.dtd">
web-app_2_3.xsd
- <?xml version="1.0" encoding="UTF-8"?>
- <!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"?> <!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_2_4.xsd
- <?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">
<?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">
web-app_2_5.xsd
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
確定web.xml裏的xsd版本之後一定要在JSP的聲明(<%@page %>)部分加一行,如下:
<%@ page isELIgnored="false" %>
這樣設爲false才能解析EL表達式。
經過各版本的test之後....
注意!! 其中servlets 2.4(我沒記錯的話JSP 2.0出來之後的第一個版本),這個版本的isELIgnored默認設置爲false。所以使用web.xml裏用web-app_2_4.xsd聲明的時候在JSP頁面不用特意聲明。
下面是官方Documention中isELIgnored Attribute的詳解:
The isELIgnored Attribute
• Format
– <%@ page isELIgnored="false" %>
– <%@ page isELIgnored="true" %>
Purpose
– To control whether the JSP 2.0 Expression Language
(EL) is ignored (true) or evaluated normally (false).
• Notes
– If your web.xml specifies servlets 2.3 (corresponding to
JSP 1.2) or earlier, the default is true
• But it is still legal to change the default—you are permitted
to use this attribute in a JSP-2.0-compliant server
regardless of the web.xml version.
– If your web.xml specifies servlets 2.4 (corresponding to
JSP 2.0) or earlier, the default is false
---------
---------
---------
---------
---------
今天在調試之前出現SSH整合asm包衝突的時候發現,tomcat下如果使用j2ee5.0,會導致EL語言的失效,這個時候需要在jsp頁面上方加上:
<%@page isELIgnored="false"%>
或者在web.xml文件中修改最上面的版本爲2.4,以及驗證的xsd爲web-app_2_4.xsd.
在web.xml中 還可以配置<jsp:config>元素:
<jsp-config> 元素主要用來設定JSP相關配置,<jsp-config> 包括<taglib>和<jsp-property-group>
子元素。
(1)其中<taglib>以前的Jsp1.2中就有的,taglib主要作用是作爲頁面taglib標籤中的uri和tld文件的一個映射關係
(2)其中<jsp-property-group>是JSP2.0種新增的元素。
<jsp-property-group> 主要包括8個子元素,它們分別是:
<jsp-property-group>
<description>
設定的說明
</description>
<display-name>設定名稱</display-name>
<url-pattern>設定值所影響的範圍</url-pattern>
<el-ignored>若爲true則不支持EL語法</el-ignored>
<page-encoding>ISO-8859-1</page-encoding>
<scripting-invalid> 若爲true則不支持<% scripting%> 語法</scripting-invalid>
<include-prelude>設置JSP網頁的擡頭,擴展名爲.jspf </include-prelude>
<include-coda>設置JSP網頁的結尾,擴展名爲.jspf</include-coda>
</jsp-property-group>