Failed to load http://localhost:8080/xxx: No 'Access-Control-Allow-Origin' header is presen...

最近学了下vuejs的东西,然后打算结合后端练习下。
后端用了(sping+spingmvc+hibernate)
结果页面报以下这个错误:

报错:Failed to load http://localhost:8080/XXXX: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.

解决办法:
Failed to load http://localhost:8080/xxx: No 'Access-Control-Allow-Origin' header is presen..._第1张图片
前端代码:vue+axios




    
    首页


  • {{index+1}}.姓名:{{item.name}},年龄:{{item.age}}

效果展示:
点击查询,数据才会出来。这里是从数据库中读取数据。
Failed to load http://localhost:8080/xxx: No 'Access-Control-Allow-Origin' header is presen..._第2张图片
Failed to load http://localhost:8080/xxx: No 'Access-Control-Allow-Origin' header is presen..._第3张图片
数据库的数据:
Failed to load http://localhost:8080/xxx: No 'Access-Control-Allow-Origin' header is presen..._第4张图片
详情代码,我另外写个文档说明。
https://blog.csdn.net/weixin_43849543/article/details/105543666

你可能感兴趣的:(vue,vue,java)