大多数时候,我们在开发J2EE应用的时候,会使用一些依赖于容器的一些配置,如:resin里有resin-web.xml,jboss里有jboss-web.xml等配置文件,这些文件主要是针对于特定容器而需要的一些配置,期目的是为了方便在各大容器间移植,然而最近发现在resin里使用resin-web.xml文件时候,造成JSP2.0里的EL表达式不能用,失效,也就是说当你在JSP文件里使用形如:${param.name}这样的语言将不起作用,获不到相应的数据,经过一些时间实验,最终发现要在web.xml文件里加入这么一段配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="union" version="2.4"
xmlns=" http://java.sun.com/xml/ns/j2ee"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<web-app id="union" version="2.4"
xmlns=" http://java.sun.com/xml/ns/j2ee"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
<page-encoding>utf-8</page-encoding>
</jsp-property-group>
</jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
<page-encoding>utf-8</page-encoding>
</jsp-property-group>
</jsp-config>
</web-app>
注意web.xml文件的声名,必须声名为servlet2.4的规范,否则EL将不会生效,如果要使用resin-web.xml文件,则web.xml文件则要声名
<el-ignored>false</el-ignored>这么一项,EL才能生效!