我试图通过网络应用获得事先/后的说明,但出于某种原因,在春季安全方面没有发生。
网络:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/rvaContext-business.xml
/WEB-INF/rvaContext-security.xml
</param-value>
</context-param>
<!-- Spring security filter -->
<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>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>rva</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rva</servlet-name>
<url-pattern>/rva/*</url-pattern>
</servlet-mapping>
rvaContext-security.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-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<global-method-security pre-post-annotations="enabled"/>
<http use-expressions="true">
<form-login login-page="/login" />
<logout />
<remember-me />
</http>
...
后勤舱:
@Controller
@RequestMapping("/login")
public class LoginController {
@RequestMapping(method = RequestMethod.GET)
public String login(ModelMap map){
map.addAttribute("title", "Login: AD Credentials");
return("login");
}
@RequestMapping("/secure")
@PreAuthorize("hasRole( ROLE_USER )")
public String secure(ModelMap map){
return("secure");
}
}