【发布时间】:2012-02-20 10:27:32
【问题描述】:
我已经构建了 Spring MVC 应用程序并将其提升到高级水平。
现在我的任务是将 Spring Security 集成到其中。我现在关注this tutorial 以获取春季安全。现在的问题是,在我的 MVC 应用程序中,已经有一个 applicationContext.xml,它是 MVC 应用程序的父应用程序上下文定义。
正如安全教程中提到的,我是否必须为安全添加一个新的应用程序上下文 xml 文件?其中包含代码:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<global-method-security secured-annotations="disabled">
</global-method-security>
<http auto-config="true">
<intercept-url pattern="/**" access="ROLE_USER" />
</http>
<authentication-provider>
<user-service id="userDetailsService">
<user name="username" password="password" authorities="ROLE_USER, ROLE_ADMIN" />
<user name="test" password="test" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</beans:beans>
提前致谢。
附: / 编辑:还是应该将其复制到我的 MVC 应用程序的原始/现有 applicationContext.xml 文件中?
【问题讨论】:
标签: xml spring spring-security