- 我在我的應用程序中使用JSF(Primefaces),Spring,Spring Security,MyBatis和PrettyFaces。
- 我有一個URL沒有被PrettyFaces映射。
- 此URL重定向到XHTML頁面。 XHTML頁面與Spring Security映射,並與我的應用程序的角色關聯
- 在XHTML頁面中,我調用了一個Authentication對象。此對象存儲用戶在我的應用程序中記錄了 。
- 當我進入到URL ocurrs一個例外,因爲Authentication對象爲空
- 但當我映射的URL,存儲Authentication對象返回值用戶。
發生了什麼事?當URL未被映射到PrettyFaces時,身份驗證(Spring Security)對象爲空
這是我的日誌web應用:
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)
這是我的春天Securiy的配置和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:我改變話題更明確
看來,這是工作:) –