扶朕起来,朕还能卷 2022-03-01 15:26
浏览 124
已结题

springboot+security 测试无返回值

问题遇到的现象和发生背景

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、有白名单

img


2、没有白名单

img


3、甚至不存在的路径 -_-||

img

运行结果及报错内容

控制台没有打印任何内容,无报错,测试用的是postman

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 3月9日
    • 创建了问题 3月1日

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么