天天看点

JSF不能解析El表达式

JSF工程在部署后,页面不能解析El表达式,及所有的JSF标签。

如:

在访问的时候显示成#{initParam['SYSPARAM_WindowTitle']}。

解决方法1:

确保web.xml中定义的版本是2.5或以上的。

注意改完后要清理tomcat work目录才能生效。

解决方法2:

在页面上加入

<%@ page isELIgnored="false" %>
           

问题原因:

JSP 2.0中,如果web-app版本为2.4或者以上的话isELIgnored默认为false, 以前的版本默认为true,需要手动在页面上加入

<%@ page isELIgnored="false" %>
           

下面是官方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