我在使用Spring boot为我的angular应用程序提供服务时遇到了问题。
@RequestMapping("/home")
public String home() {
return "index";
}文件夹结构
resources > public > index.html如果我转到localhost:8080/home,我会得到这个错误:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback.
Mon Dec 17 13:30:33 CET 2018
There was an unexpected error (type=Internal Server Error, status=500).
Could not resolve view with name 'index' in servlet with name 'dispatcherServlet'但是,如果我直接转到http://localhost:8080/index.html,它确实可以工作
如果我直接转到http://localhost:8080,我会得到:
No mapping for GET /发布于 2018-12-17 20:50:12
你放置在resources/public下的文件是用于静态托管文件的--这是你放置html登录页面、css、图片和JS资源的地方--在代码中不需要请求映射。
您的代码示例应该只返回已定义的字符串,但是如果看不到代码的其余部分,就很难说出失败的原因。
https://stackoverflow.com/questions/53815458
复制相似问题