我遵循本教程将Sping Boot 与AngularJS集成:
https://dzone.com/articles/java-8-springboot-angularjs-bootstrap-springdata-j
我在Eclipse/Photon中用STS构建了Sping Boot starter。我的Eclipse项目看起来像这样:
x1c 0d1x的数据
我的“Home”控制器看起来像这样:
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/home")
public String home() {
return "index";
}
}
字符串
根据上面的截图,我在src/main/resources/static/views中有一个“index.html”。
我的application.properties定义了spring.mvc.view.prefix和.suffix:
spring.mvc.view.prefix = /views/
spring.mvc.view.suffix = .html
型
当我右键单击Eclipse项目和“Run As > Spring App”时,没有错误或警告。
但是当我浏览localhost:8080/home时,我得到:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Nov 03 13:40:19 PDT 2018
There was an unexpected error (type=Not Found, status=404).
No message available
型
为什么我尝试访问“/home”时出现“404”?
在Eclipse中,我的Eclipse项目中有什么“特殊”需要做的吗?
有哪些好的故障排除策略?
1条答案
按热度按时间ttygqcqt1#
我相信你没有使用模板引擎,如
thymeleaf
。尝试以下方法,它应该可以解决您的问题。
1.将您的
index.html
移动到src/main/resources/static
。这是将自动提供HTML
文件等静态资源的位置。1.您可以删除在
application.properties
文件中定义的这两行。