springboot使用拦截器
拦截器:Interceptor 在AOP(Aspect-Oriented Programming)中用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加入某些操作。比如日志,安全等。一般拦截器方法都是通过动态代理的方式实现。可以通过它来进行权限验证,或者判断用户是否登陆
案例
- 创建一个接口
/**
* @author Gjing
**/
@RestController
public class TestController {
@PostMapping("/test")
@ApiOperation(value = "测试", httpMethod = "POST")
public ResponseEntity test() {
return ResponseEntity.ok("ok"