无法将prettyfaces与jsf集成

hit*_*ani 2 jsf-2 prettyfaces

我需要将漂亮的面孔与我的jsf 2.0,primefaces应用程序集成,但它会带来一些麻烦.

正如在入门中所提到的,我在我的web.xml中放置了以下内容,在lib文件夹中添加了所需的jar

<filter>
  <filter-name>Pretty Filter</filter-name>
  <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
  <async-supported>true</async-supported>
 </filter>

 <filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
 </filter-mapping>
Run Code Online (Sandbox Code Playgroud)

我的web.xml中的其他项目

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
  </context-param>
  <context-param>
        <param-name>org.primefaces.extensions.DELIVER_UNCOMPRESSED_RESOURCES</param-name>
        <param-value>false</param-value>
  </context-param>
Run Code Online (Sandbox Code Playgroud)

但我得到以下错误:

Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/javaee":init-param}' is expected

如果我<async-supported>从项目构建中删除 ,项目编译但映射不起作用.

pretty-config.xml 与入门时相同.

我需要在web.xml中提到映射文件的名称/路径,即pretty-config.xml吗?

编辑:

我正在使用Glassfish服务器3.

chk*_*kal 5

检查version您正在使用的属性非常重要web.xml.如果已version="2.5"设置,则必须将其添加到web.xml:

<filter>
  <filter-name>Pretty Filter</filter-name>
  <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping> 
  <filter-name>Pretty Filter</filter-name> 
  <url-pattern>/*</url-pattern> 
  <dispatcher>FORWARD</dispatcher> 
  <dispatcher>REQUEST</dispatcher> 
  <dispatcher>ERROR</dispatcher>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)

请不要<async-supported>true</async-supported>在此处设置,因为它仅在Servlet 3.0中受支持.

如果已version="3.0"在web.xml中设置,则无需向web.xml添加任何内容.在这种情况下,PrettyFaces会使用web-fragment.xml包含的过滤器自动注册过滤器prettyfaces-jsf2.jar.

您不必指定pretty-config.xml任何位置.只需将其放在您的WEB-INF文件夹中,PrettyFaces就会找到它.

您还应该为您添加一个映射pretty-config.xml,以便检查一切是否正常.例如,如果您有一个通常使用以下URL访问的页面:

http://localhost:8080/myapp/faces/login.xhtml
Run Code Online (Sandbox Code Playgroud)

然后你可以添加这个映射:

<url-mapping id="login">
  <pattern value="/login" />
  <view-id value="/faces/login.xhtml" />
</url-mapping>
Run Code Online (Sandbox Code Playgroud)

现在您应该可以使用以下链接访问该页面:

http://localhost:8080/myapp/login
Run Code Online (Sandbox Code Playgroud)