我试图从属性文件中获取一个简单的值。它适用于我的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控制器中,这些工作正常。在我的spring security登录处理程序中,这是一个扩展SavedRequestAwareAuthenticationSuccessHandler
的类,它们都返回null
。这是我的spring-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 :(得分:0)
BeanFactory(Post)Processor
仅对其定义的上下文进行操作。
<context:property-placeholder .. />
中定义的spring-servlet.xml
对spring-security.xml
中的bean没有任何作用。第一个由DispatcherServlet
加载,而第二个由ContextLoaderListener
加载。
你必须申报两次我害怕。