最近在学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请求,欣赏器会阻止这个请求,除非服务器端明白允许此类跨域请求。