0
  1. アプリケーションで JSF(Primefaces)、Spring、Spring Security、MyBatis、PrettyFaces を使用しています。
  2. PrettyFaces によってマップされていない URL があります。
  3. この URL は XHTML ページにリダイレクトされます。XHTML ページは Spring Security でマッピングされ、アプリケーションのロールに関連付けられています
  4. XHTML ページで、Authenticationオブジェクトを呼び出します。このオブジェクト ストア ユーザーがアプリケーションにログインしました。
  5. 認証オブジェクトがnullであるため、URLに入力すると例外が発生します
  6. しかし、url をマッピングすると、 Authenticationオブジェクトの戻り値にユーザーが格納されます。

何が起こっていますか?

これは私の webapp のログです:

40094 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Initialized PrettyContext
 40094 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Initialized PrettyContext
 40094 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyFilter  - Request is not mapped using PrettyFaces. Continue.
 40094 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Initialized PrettyContext
 40094 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - PrettyContext not found in Request - building new instance
 40094 [http-8080-6] DEBUG org.springframework.faces.support.RequestLoggingPhaseListener  - Entering JSF Phase: RESTORE_VIEW 1
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Retrieved PrettyContext from Request
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.faces.beans.ParameterInjector  - Validating parameters.
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Retrieved PrettyContext from Request
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.faces.beans.ParameterInjector  - Injecting parameters
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Retrieved PrettyContext from Request
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Retrieved PrettyContext from Request
 40141 [http-8080-6] INFO  com.indra.siguip.view.exceptions.SiguipExceptionHandler  - Entrando al manejador de Excepciones del JSF
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Retrieved PrettyContext from Request
 40141 [http-8080-6] DEBUG org.springframework.faces.support.RequestLoggingPhaseListener  - Entering JSF Phase: APPLY_REQUEST_VALUES 2
 40141 [http-8080-6] INFO  com.indra.siguip.view.exceptions.SiguipExceptionHandler  - Entrando al manejador de Excepciones del JSF
 40141 [http-8080-6] TRACE com.ocpsoft.pretty.PrettyContext  - Retrieved PrettyContext from Request
 40141 [http-8080-6] DEBUG org.springframework.faces.support.RequestLoggingPhaseListener  - Entering JSF Phase: PROCESS_VALIDATIONS 3
 40141 [http-8080-6] TRACE org.springframework.web.jsf.el.SpringBeanFacesELResolver  - Successfully resolved variable 'applicationConfig' in Spring BeanFactory
 40141 [http-8080-6] TRACE org.springframework.web.jsf.el.SpringBeanFacesELResolver  - Successfully resolved variable 'menuGeneratorService' in Spring BeanFactory
 28/05/2013 07:54:00 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
ADVERTENCIA: Se ha producido un error al realizar la inyección de recurso en el bean administrado menuController
com.sun.faces.mgbean.ManagedBeanCreationException: Se ha producido un error al realizar la inyección de recurso en el bean administrado menuController
    at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:229)

これは、Spring Secury と PretyFaces の私の構成です

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

PD: トピックをより明確なものに変更しました

4

2 に答える 2

1

FORWARD リクエストを処理するように 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>
  <dispatcher>INCLUDE</dispatcher>
  <dispatcher>ERROR</dispatcher>
</filter-mapping>

フレームワークによって処理されない場合、PrettyFaces はリクエストを転送しません。したがって、ディスパッチ タイプは REQUEST のままであり、Spring Security フィルターは実行されません。

于 2013-05-29T15:20:14.830 に答える