/test到/home/index.jsf的URL映射只会导致404

/test到/home/index.jsf的URL映射只会导致404,jsf,jsf-2,url-rewriting,prettyfaces,Jsf,Jsf 2,Url Rewriting,Prettyfaces,我一直在尝试设置OCPsoft对JSF2.2的重写 我的设置: JSF2.2 雄猫7 Servlet容器3.0 马文项目 URL重写版本2.0.12 mypom.xml包含以下两个依赖项 <!-- for JSF 2.x --> <dependency> <groupId>org.ocpsoft.rewrite</groupId> <artifactId>rewrite-servlet<

我一直在尝试设置OCPsoft对JSF2.2的重写

我的设置:

  • JSF2.2
  • 雄猫7
  • Servlet容器3.0
  • 马文项目
  • URL重写版本2.0.12
mypom.xml包含以下两个依赖项

<!-- for JSF 2.x -->
    <dependency>
        <groupId>org.ocpsoft.rewrite</groupId>
        <artifactId>rewrite-servlet</artifactId>
        <version>2.0.12.Final</version>
    </dependency>
    <dependency>
        <groupId>org.ocpsoft.rewrite</groupId>
        <artifactId>rewrite-config-prettyfaces</artifactId>
        <version>2.0.12.Final</version>
    </dependency>

org.ocpsoft.rewrite
重写servlet
2.0.12.1最终版本
org.ocpsoft.rewrite
重写配置面
2.0.12.1最终版本
我在WEB-INF文件夹中放置了一个pretty-config.xml

    <pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

    <url-mapping id="test">
        <pattern value="/test" />
        <view-id value="/home/index.jsf" />
    </url-mapping>

</pretty-config>

My web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    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>myproject</display-name>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/resources/*</url-pattern>
    </servlet-mapping>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <context-param>
        <param-name>org.omnifaces.CDN_RESOURCE_HANDLER_URLS</param-name>
        <param-value>primefaces:jquery/jquery.js=http://code.jquery.com/jquery-1.11.0.min.js</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>State saving method: "client" or "server" (= default) 
        See JSF Specification 2.5.2. Zur Produktion wieder auf server schalten. HTTP 
        GET Request zusammen mit 'client'
    führen zum Verlust des STATE</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <description>Next step - disable compression of state in server</description>
        <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <description>If true, rendered HTML code will be formatted, so that 
            it is "human readable". i.e. additional line separators and whitespace will 
            be written, that do not influence
        the HTML code. Default: "true"</description>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>Very important, too, is to disable the serialization 
        of state, serialization and deserialization of the component tree is a
        major
        performance hit
    </description>
        <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>
    <!-- Verschlüsselung des Viewstates -->
    <context-param>
        <param-name>org.apache.myfaces.secret</param-name>
        <param-value>NzY1NDMyMTA=</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.numberOfViewsInSession</param-name>
        <param-value>3</param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.numberOfLogicalViews</param-name>
        <param-value>10</param-value>
    </context-param>
    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>404</error-code>
        <location>/error/404.jsf</location>
    </error-page>
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/home/index.jsf</location>
    </error-page>

    <filter>
        <filter-name>adminPinFilter</filter-name>
        <filter-class>com.myproject.filters.AdminPinFilter</filter-class>
    </filter>
    <filter>
        <filter-name>facesRedirectFilter</filter-name>
        <filter-class>com.myproject.filters.FacesRedirectFilter</filter-class>
        <init-param>
            <description>Auf diese Extension soll nicht direkt zugegriffen
                    werden
                    (z.B. .xhtml)</description>
            <param-name>forbiddenExtension</param-name>
            <param-value>.xhtml</param-value>
        </init-param>
        <init-param>
            <description>Auf diese Extension soll umgeleitet werden (z.B. .jsf)</description>
            <param-name>redirectExtension</param-name>
            <param-value>.jsf</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>directGetFilter</filter-name>
        <filter-class>com.myproject.filters.DirectGetFilter</filter-class>
    </filter>
    <filter>
        <filter-name>hibernateFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter>
        <filter-name>sessionFilter</filter-name>
        <filter-class>com.myproject.filters.SessionFilter</filter-class>
    </filter>
    <filter>
        <filter-name>authFilter</filter-name>
        <filter-class>com.myproject.filters.AuthFilter</filter-class>
    </filter>
    <filter>
        <filter-name>offerFilter</filter-name>
        <filter-class>com.myproject.filters.OfferFilter</filter-class>
    </filter>
    <filter>
        <filter-name>adminAuthFilter</filter-name>
        <filter-class>com.myproject.filters.AdminAuthFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>hibernateFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>adminPinFilter</filter-name>
        <url-pattern>/adminPin/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>facesRedirectFilter</filter-name>
        <url-pattern>*.xhtml</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>sessionFilter</filter-name>
        <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>authFilter</filter-name>
        <url-pattern>/profile/*</url-pattern>
        <url-pattern>/conversation/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>adminAuthFilter</filter-name>
        <url-pattern>/admin/panel/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>offerFilter</filter-name>
        <url-pattern>/offer/view/*</url-pattern>
    </filter-mapping>

    <session-config>
        <!-- Disables URL-based sessions (no more 'jsessionid' in the URL using 
            Tomcat) -->
        <tracking-mode>COOKIE</tracking-mode>
    </session-config>

    <listener>
        <listener-class>com.myproject.system.ContextFinalizer</listener-class>
    </listener>
</web-app>

我的项目
违约
/资源/*
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.request.RequestContextListener
javax.faces.PROJECT_阶段
生产
上下文配置位置
/WEB-INF/applicationContext.xml
org.omnifaces.CDN\u资源\u处理程序\u URL
primefaces:jquery/jquery.js=http://code.jquery.com/jquery-1.11.0.min.js
javax.faces.FACELETS\u跳过\u注释
真的
状态保存方法:“客户端”或“服务器”(=默认值)
参见JSF规范2.5.2。Zur生产wieder auf服务器schalten。超文本传输协议
获取请求zusammen mit“客户”
弗伦·祖姆·维卢斯特州
javax.faces.STATE_保存方法
服务器
下一步-禁用服务器中的状态压缩
org.apache.myfaces.COMPRESS\u STATE\u IN\u会话
假的
如果为true,则将格式化呈现的HTML代码,以便
它是“人类可读的”。i、 e.将添加额外的行分隔符和空格
被写下来,那不会影响你
HTML代码。默认值:“true”
org.apache.myfaces.PRETTY_HTML
真的
禁用序列化也是非常重要的
对于状态,组件树的序列化和反序列化是
专业
演出命中率
org.apache.myfaces.SERIALIZE_STATE_IN_SESSION
假的
org.apache.myfaces.secret
NzY1NDMyMTA=
com.sun.faces.numberofviewsin会话
3.
com.sun.faces.numberofLogicalView
10
/index.jsp
404
/错误/404.jsf
javax.faces.application.ViewExpiredException
/home/index.jsf
管理员过滤器
com.myproject.filters.adminFilter
FacesDirectFilter
com.myproject.filters.facesDirectFilter
Auf diese扩展解决方案
沃登
(z.B..xhtml)
禁止扩展
.xhtml
Auf diese扩展至umgeleitet werden(z.B..jsf)
重定向扩展
.jsf
directGetFilter
com.myproject.filters.DirectGetFilter
冬眠过滤器
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter
会话过滤器
com.myproject.filters.SessionFilter
authFilter
com.myproject.filters.AuthFilter
过滤器
com.myproject.filters.OfferFilter
adminAuthFilter
com.myproject.filters.AdminAuthFilter
冬眠过滤器
/*
要求
向前地
管理员过滤器
/管理员/*
FacesDirectFilter
*.xhtml
会话过滤器
*.jsf
authFilter
/侧面图/*
/谈话/*
adminAuthFilter
/行政/事务委员会/*
过滤器
/提供/查看/*
曲奇
com.myproject.system.ContextFinalizer
然而,如果我导航到/test,我只会得到一个404错误


我遗漏了什么吗?

您的web应用程序中是否有一个名为“/home/index.xhtml”的文件(或类似的文件)?如果可能的话,也请发布您的web.xml。谢谢

另外,在web.xml中似乎定义了很多过滤器,但没有定义重写过滤器。这应该很好,但是,手动添加过滤器并查看发生了什么是值得的。重写筛选器应该是web.xml中的第一个筛选器:

<listener>
   <listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletRequestListener</listener-class>
</listener>

<listener>
   <listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletContextListener</listener-class>
</listener>

<filter>
   <filter-name>OCPsoft Rewrite Filter</filter-name>
   <filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
   <async-supported>true</async-supported>
</filter>
<filter-mapping>
   <filter-name>OCPsoft Rewrite Filter</filter-name>
   <url-pattern>/*</url-pattern>
   <dispatcher>FORWARD</dispatcher>
   <dispatcher>REQUEST</dispatcher>
   <dispatcher>INCLUDE</dispatcher>
   <dispatcher>ASYNC</dispatcher>
   <dispatcher>ERROR</dispatcher>
</filter-mapping>

org.ocpsoft.rewrite.servlet.impl.RewriteServletRequestListener
org.ocpsoft.rewrite.servlet.impl.RewriteServletContextListener
OCPsoft重写过滤器
org.ocpsoft.rewrite.servlet.RewriteFilter
真的
OCPsoft重写过滤器
/*
向前地
要求
包括
异步的
错误

现在一切正常。我从web.xml中删除了默认servlet

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/resources/*</url-pattern>
</servlet-mapping>

违约
/资源/*

编辑了上面的帖子,是的,我的主目录中有index.xhtml编辑了我的答案,再试一次?在上面添加了过滤器和侦听器,没有更改。好的,在使用servlet容器3.0时,最新版本的重写不需要额外的过滤器。没错,我只是想确保顺序正确。六羟甲基三聚氰胺六甲醚。。。您是否认为您可以在支持论坛上发布并附加一个复制此问题的示例应用程序(或上传并在其他地方共享指向此问题的链接)?我应该能够在应用程序上提供更多帮助:(如果您在创建帐户时遇到问题,请告诉我。)