我想为我的Spring MVC应用程序配备身份验证。为此,我以下列方式使用Spring安全性:
(编辑:我创建了一个新的测试项目,以便在一个地方进行所有配置)
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans ...>
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<sec:http auto-config='true'>
<sec:intercept-url pattern="/**" access="ROLE_USER" />
</sec:http>
<sec:authentication-manager>
<sec:authentication-provider>
<sec:user-service>
<sec:user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" />
<sec:user name="bob" password="bobspassword" authorities="ROLE_USER" />
</sec:user-service>
</sec:authentication-provider>
</sec:authentication-manager>
<context:component-scan base-package="de.emundo.project" />
</beans:beans>
如果我从部署的服务器请求任何页面,则不会进行登录重定向。就好像没有包含spring-security.xml一样(显然它是这样)。
我在这里错过了什么吗?