Reputation: 121619
I'm following this tutorial to integrate Spring Boot with AngularJS:
https://dzone.com/articles/java-8-springboot-angularjs-bootstrap-springdata-j
I built the Spring Boot starter with STS in Eclipse/Photon. My Eclipse project looks like this:
My "Home" Controller looks like this:
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";
}
}
Per the screenshot above, I have an "index.html" in src/main/resources/static/views.
My application.properties defines spring.mvc.view.prefix and .suffix:
spring.mvc.view.prefix = /views/
spring.mvc.view.suffix = .html
There are no errors or warnings when I right-click the Eclipse project and "Run As > Spring App".
But when I browse to localhost:8080/home, I get:
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
Why am I getting a "404" trying to access "/home"?
Is there anything "special" I need to do in Eclipse, with my Eclipse project?
What are some good strategies for troubleshooting?
Upvotes: 0
Views: 1382
Reputation: 2511
I believe you are not using templating engine such as thymeleaf
.
Try the following and it should fix your problem.
index.html
to src/main/resources/static
. This is the location from where static resources like HTML
file will be served automatically. application.properties
file.Upvotes: 1