{“msg“:“invalid token“,“code“:401}

Project scenario:

提示:这里简述项目相关背景:

{"msg":"invalid token","code":401}
When the front-end requests the back-end interface, the request fails, and the following error message appears on the console

Problem Description

问题:

The console error message is as follows:

{
    
    “msg“:“invalid token“,“code“:401}

Cause Analysis:

analyse problem:

Analysis:
1. Check whether the @RequiresPermissions ("") permission control at the interface is commented 2.
Whether the interface is opened in shiroFilter.class
3. Check the access path and the interface configuration in the configuration file

According to the analysis of the actual situation of the project, because the module does not have a login account, the requested interface needs to be configured in the ShiroConfig file, so that the interface can be requested directly without verification.

solution:

Solution:

Configure accordingly in the ShiroConfig file

1. Front-end request interface
insert image description here

2. Make corresponding configuration in the ShiroConfig file
insert image description here

3. Writing the interface

   @PostMapping("/tid")
    @ApiOperation("设备列表")
    public R tid(@RequestBody Map<String ,Object> params) {
   
            //TODO
}

My problem is solved! ! !

Guess you like

Origin blog.csdn.net/YHLSunshine/article/details/131817154