解决前端“CORS 头缺少 ‘Access-Control-Allow-Origin‘“问题
作者:互联网
问题:
在HbuilderX中使用mui.ajax()函数访问后台数据时,发现出现:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
解决:
在后台Controller类上加入:
@CrossOrigin(origins = "*", maxAge = 3600)
如:
@CrossOrigin(origins = "*", maxAge = 3600)
public class UserController {
标签:Control,Origin,3600,CrossOrigin,maxAge,Access,Allow 来源: https://blog.csdn.net/qq_41915623/article/details/117453619