2014-10-06 1 views
0

OCPsoft의 재 작성 http://ocpsoft.org/rewrite/examples/을 JSF 2.2 용으로 설정하려고했습니다./home/index.jsf에 대한/test의 URL 매핑은 404 결과 만 제공합니다.

내 설정 :

  • JSF 2.2
  • 톰캣 7
  • 서블릿 컨테이너는 3.0
  • 메이븐 프로젝트는
  • URLRewrite 버전 2.0.12는

내 pom.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> 

그러나 내 WEB-INF 폴더

<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> 

내 web.xml 파일에 꽤-config.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> 

404 오류 만 나타납니다.

내가 빠진 것이 있습니까?

답변

0

모든 것이 올바르게 작동합니다. web.xml에서 기본 서블릿을 제거했습니다.

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

"/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> 
+0

위의 내 게시물을 편집했습니다. 예, 내 홈 디렉토리에 index.xhtml이 있습니다. – kevcodez

+0

내 대답을 편집 했습니까? 다시 시도하십시오. – Lincoln

+0

위 필터 및 수신기를 추가했으나 변경되지 않았습니다. AFAIK, 서블릿 컨테이너 3.0을 사용하는 동안 최신 버전의 다시 쓰기에 필요한 추가 필터가 없습니다. – kevcodez