tomcat7+El2.2+jsf1.2 不工作
表达式语言在带有 jsf1.2 的 tomcat7 中不起作用。#{message.name_prompt}
被输出为 #{message.name_prompt}
。
我尝试用 el-api-2.2.jar 替换 tomcat lib 文件夹中的 el-api.jar 并放入 el-impl-2.2.jar 在WEB-INF/lib文件夹中,添加
<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
到web.xml。还是一样。
我的 tomcat 确切版本是 *7.0.21*这是具有默认 tomcat 设置的 web.xml:
<?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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>BasicExamples</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
更新: 现在我发现表达式语言在表单页面上不起作用,但消息表达式语言的工作方式为 #{message.result_text}
=>您输入了以下信息
: ,但托管 bean 仍然无法工作。 并且 El 与 jsf2.0 配合良好
expression language is not working in tomcat7 with jsf1.2 .#{message.name_prompt}
is ouputed as #{message.name_prompt}
.
i tried to replace the el-api.jar in the tomcat lib folder with el-api-2.2.jar and put the el-impl-2.2.jar in the WEB-INF/lib folder, adding
<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
to the web.xml. stilll the same.
my tomcat exact version is *7.0.21*this is the web.xml with the default tomcat setting:
<?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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>BasicExamples</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
update:
now i find that the expression language is not working on the form page but the message expression language is working as #{message.result_text}
=>You entered the following information
: ,but still managed bean not working.
and El is working fine with jsf2.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无需安装/添加任何内容即可让 EL 2.2 在 Tomcat 7 中工作。它已经随 EL 2.2 一起提供。删除这些 JAR 和上下文参数。
鉴于您的症状
我的印象是您正在谈论在模板文本中使用 EL,例如:
This is <不是 EL 2.2 功能。这是 Facelets 的一项功能。 Facelets 是 JSP 的继承者。您需要将 JSP 替换为 Facelets,以便能够在模板文本中使用 EL。对于 JSF 1.2,您可以使用 Facelets 1.1。
否则,当您想坚持使用 JSP 时,您确实需要使用
:唯一的新 EL 2.2 功能是能够使用参数调用操作方法,例如:
另请参阅:
You don't need to install/add anything to get EL 2.2 to work in Tomcat 7. It already ships with EL 2.2. Remove those JARs and the context param.
Given your symptoms
I have the impression that you're talking about using EL in template text something like:
This is not an EL 2.2 feature. This is a Facelets feature. Facelets is the successor of JSP. You need to replace JSP by Facelets in order to be able to use EL in template text like that. For JSF 1.2, you can use Facelets 1.1.
Otherwise, when you want to stick to JSP, you really need to use
<h:outputText>
:The only new EL 2.2 feature is the ability to invoke action methods with arguments, e.g.:
See also: