我正在尝试添加 Spring 安全性,但无法使其正常工作。但是我原以为这会导致浏览器弹出一个对话框,询问用户名和密码,但没有显示任何内容。它只是给我带来了正常的页面,而没有强制执行任何安全措施。使用 Spring 3.1:
web.xml
:
<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>
</filter-mapping>
context.xml
:
<security:http>
<security:http-basic />
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="test" password="testpass" authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>