问答详情
源自:3-11 用户模型管理--用户注册功能实现02

前端又有跨域问题

后端添加代码

@CrossOrigin(allowCredentials="true",allowedHeaders="*")

前端页添加代码

xhrFields:{withCredentials:true},

添加后本来已经解决的跨域问题又出现了:

getotp.html:1 Failed to load http://localhost:8090/user/getotp: The 'Access-Control-Allow-Origin' header has a value 'null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.

有人遇到相同问题吗?

提问者:88aa 2019-04-25 20:43

个回答

  • 陈闽不会算法复杂度
    2019-04-26 10:53:51

    前端有加这个吗?

    contentType:"application/x-www-form-urlencoded"

    public static final String CONTNET_TYPE_FORMED = "application/x-www-form-urlencoded";

    后端:

    @RequestMapping(value = "/getotp", method = {RequestMethod.POST}, consumes = {CONTNET_TYPE_FORMED})
    @ResponseBody