Spring Security使用Servlet中的Filter保护Web请求限制URL级别的访问;使用Spring AOP保护方法调用——借助对象代理和通知。
1、添加Spring Security依赖
2、启用Spring Security,Spring Security是借助一系列Servlet Filter来提供web层的安全功能,但我们只需要声明一个Filter——DelegatingFilterProxy即可。
web.xml: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter>