问题遇到的现象和发生背景
springboot+security整合,测试接口的时候无论是不是白名单接口都可以访问成功,状态为200,但是无返回数据,浏览器测试也是一样,求解
问题相关代码,请勿粘贴截图
控制类
@Controller
public class TestController {
@GetMapping("/test")
@ResponseBody
public Result test(){
System.out.println("开始测试");
return Result.success("成功!","你好");
}
@GetMapping("/test1")
@ResponseBody
public String test1(){
System.out.println("开始测试");
return "你好!";
}
}
配置类
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Resource
private JwtAccessDeniedHandler jwtAccessDeniedHandler;
@Resource
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
@Resource
private JwtAuthenticationFilter jwtAuthenticationFilter;
/**
* 一般用于配置白名单
* 白名单:可以没有权限也可以访问的资源
* @param web
* @throws Exception
*/
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.mvcMatchers("/test");
}
测试结果截图
1、有白名单
2、没有白名单
3、甚至不存在的路径 -_-||
运行结果及报错内容
控制台没有打印任何内容,无报错,测试用的是postman