el 表达式没法解析

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

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!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

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!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

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <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

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章