我是 richfaces 的新手,我想使用注释而不是 xml 配置来支持 bean 类 [就像 JSF 2.0] 我正在使用 richfaces 4.0 并将所有必需的 jar 包含在我的构建路径中。但当我尝试 import javax.faces.bean.*;
它通过没有找到包的错误。如果我包含来自 mojarra 的核心 JSF2.0 jar,它可以正常编译,但是当导出为 war 文件时,tomcat v7 会引发错误,并且我的项目无法执行。
请提供任何帮助。
附注没有任何bean,该项目运行良好
最佳答案
if I include the core JSF2.0 jar from mojarra it compiles fine
没错。 Tomcat 不附带任何现成的 JSF 库。 RichFaces4 也不附带任何特定的 JSF 实现。您需要在 /WEB-INF/lib
文件夹中拥有 jsf-api.jar
和 jsf-impl.jar
。
but when expoted as an war file the tomcat v7 raising an error and my project fail to execute.
您需要确保您的 /WEB-INF/faces-config.xml
声明符合 JSF 2.0 规范。
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_2_0.xsd"
version="2.0"
>
<!-- Your config here (if any) -->
</faces-config>
您还需要确保您的 /WEB-INF/web.xml
声明符合 Servlet 3.0 规范或至少 Servlet 2.5 规范。
<?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"
version="3.0"
>
<!-- Your config here (if any) -->
</web-app>
关于java - Richfaces 中带注释的 ManagedBean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6050702/