2014-05-20 98 views
0

我想只是從屬性文件中獲取一個簡單的值。它適用於我的SpringMVC類,但不適用於我的SavedRequestAwareAuthenticationSuccessHandler類。春天自動裝置環境

在爲spring-servlet.xml

我已經定義:

<context:property-placeholder location="file:/TcatServer6/myapp/properties/myapp/myapp.properties" /> 

在代碼中,我有:

@Value("${anotherapp_url}") 
private String anotherAppURL; 

@Autowired 
private Environment environment; 

在我的Spring MVC控制器,這些工作就好了。在我的彈簧安全登錄處理程序中,這是一個擴展爲SavedRequestAwareAuthenticationSuccessHandler的類,它們都返回null。這是我的彈簧security.xml文件

<beans:bean id="adsh" class="com.cs.mytime.agentdesktop.security.ADAuthenticationSuccessHandler"/> 

<http auto-config="true"> 
    <intercept-url pattern="/agent/**" access="ROLE_AGENT" /> 
    <form-login 
     login-page="/r/views/login.html" 
     authentication-failure-url="/r/views/loginfailed.html" 
     authentication-success-handler-ref="adsh" 
    /> 
    <logout logout-success-url="/logout" /> 
</http> 

我已經通過在互聯網上一噸的東西讀然而,這始終是空,似乎無法得到它的工作。這個不成立。

+0

'spring-security.xml'如何被引導?它是否被包含在其他文件中? – geoand

回答

0

BeanFactory(Post)Processor唯一對他們在規定的情況下進行操作。

<context:property-placeholder .. />定義在spring-servlet.xml什麼也不做在spring-security.xml豆。第一個由DispatcherServlet加載,而第二個由ContextLoaderListener加載。

你必須申報兩次恐怕。