万万哇 发表于 2025-2-14 23:33:28

关于黑马ssm课程中P58 ssm整合中axios传参数路径题目

最近在学ssm整合过程中在页面数据渲染出现了题目,题目报错如下:
   Download the Vue Devtools extension for a better development experience: https://github.com/vuejs/vue-devtools vue.js:17105 You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html :8080/books:1 Failed to load resource: the server responded with a status of 404 () axios-0.18.0.js:15 Uncaught (in promise) Error: Request failed with status code 404 at e.exports (axios-0.18.0.js:15:4483) at e.exports (axios-0.18.0.js:15:4325) at l. (axios-0.18.0.js:15:3282) :8080/books:1 Failed to load resource: the server responded with a status of 404 () axios-0.18.0.js:15 Uncaught (in promise) Error: Request failed with status code 404 at e.exports (axios-0.18.0.js:15:4483) at e.exports (axios-0.18.0.js:15:4325) at l. (axios-0.18.0.js:15:3282) :8080/books:1 Failed to load resource: the server responded with a status of 404 () axios-0.18.0.js:15 Uncaught (in promise) Error: Request failed with status code 404 at e.exports (axios-0.18.0.js:15:4483) at e.exports (axios-0.18.0.js:15:4325) at l. (axios-0.18.0.js:15:3282)
可以看出404报的是路径题目,之后我检查了路径,最后解决方法如下:
1.在bookcontroller中增加@crossorigin注解,用于处置惩罚跨域资源共享(Cross-Origin Resource Sharing, CORS)题目。在Web应用开发中,出于安全原因,欣赏器实施了同源策略,这一策略限制了从一个源加载的Web页面脚本与来自差别源的资源交互。这意味着,如果尝试从一个域名的网页通过JavaScript向另一个域名发送AJAX请求,欣赏器会阻止这个请求,除非服务器端明白允许此类跨域请求。
https://i-blog.csdnimg.cn/direct/7828a6f87f9041c7ac943d4ba2c6f0f3.png
2.将ajax请求路径改为…/books
https://i-blog.csdnimg.cn/direct/5dd7ee80a5d644c9975e7c534dca3c53.png
3.另外发起如今学ssm的同砚不要用教程中的tomcat7插件了,可以用自己下载的可以避免很多题目
   最后,我是微笑向阳,期待与你的共同进步!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 关于黑马ssm课程中P58 ssm整合中axios传参数路径题目