1

この投稿に関する一般的な URL を作成するために、3.3.1-SNAPSHOT バージョンをダウンロードしました。

Pretty Faces: 汎用 URL マッピング

私の構成は次のとおりです。

私の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_2_5.xsd&quot; id="WebApp_ID" version="2.5">
  <display-name>myapp</display-name>

  <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>contextConfigLocation</param-name>
        <param-value>
        classpath:META-INF/spring/applicationContext.xml
        classpath:META-INF/spring/applicationSecurity.xml
        </param-value>

  </context-param>

  <!-- Activating the Expression Language -->
    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>

  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

  <welcome-file-list>
    <welcome-file>users</welcome-file>
  </welcome-file-list>

  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>

  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>

  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>

  <context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
  </context-param>

  <!-- Spring Security -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

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

  <servlet>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/xmlhttp/*</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <url-pattern>/icefaces/*</url-pattern>
  </servlet-mapping>

</web-app>

私のきれいなconfig.xml:

<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.0
               http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.0.xsd"&gt;

    <url-mapping id="generic">
    <pattern value="/*" />
    <view-id value="/faces/$1.xhtml" />
    </url-mapping>

</pretty-config>

次の行が端末で繰り返されます。

at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183) at

4

1 に答える 1

1

ミカ、

これは、PrettyFaces が URL マッピング構造を使用してサポートするものではありません。代わりに、カスタムの書き換えルールを使用する必要があります。

<rewrite match="/(.*)" substitute="/faces/$1.xhtml" />

ただし、そのようなルールの影響を考慮してください (上記で定義したものと同様です)。もちろん、「*」は「/faces/XXX.xhtml」にも一致するため、無限ループが発生します。一致パターンをより制限する必要があります。

<rewrite match="^/(.*)(?<!\.xhtml)$" substitute="/faces/$1.xhtml" />

「/*」は、あなたが思っているようなことをする正規表現ではないので、正規表現についても読むことをお勧めします: http://ocpsoft.com/opensource/guide-to-regular-expressions- in-java-part-2/#lookaround

ただし、このようなタスクを実行するために特別に設計された URL 書き換えツールが必要な場合は、OCPsoft Rewrite: http://ocpsoft.com/rewrite/を参照することをお勧めします。 ) URL 書き換えツール。

次のようなことができます。

       .addRule(Join.path("/{page}")
                .to("/pages/{page}.xhtml")
                .when(Resource.exists("/pages/{page}.xhtml"))
                .where("page").matches("(?!RES_NOT_FOUND)[^/]+"))
于 2011-11-25T19:48:48.057 に答える