14 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.

1.解决跨域问题
14 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource._第1张图片
2.添加注解 @CrossOrigin

@RestController
@CrossOrigin
public class UserController extends BaseController{
}

即可解决!

或者在方法名上加response.setHeader(“Access-Control-Allow-Origin”,“*”)

 @GetMapping("getUsersAll")
    public  Map<String,Object>getUsersAll(HttpServletResponse response){
        response.setHeader("Access-Control-Allow-Origin","*");//加入该代码
        List<UserEntity> list=userService.getUsersAll();
        return setResult(200,"ok",list);
    }

你可能感兴趣的:(SpringMVC,spring)