I'm experimenting on re-writing my configuration-heavy, vanilla Spring MVC project using Spring Boot. I started a brand new Spring Boot project in IntelliJ using the Spring Boot Initiaizer and I'm going the route of minimal Java-based configuration. Lots of tutorials point out that the default main class generated is sufficient and that @SpringBootApplication
has everything included. I got a sample REST Controller to work and return a serialized object as JSON, but it appears getting a view to show is proving difficult. My structure is as follows, with everything default other than the webapps directory which I created.
src
`-main
`-java
`-resources
`-static
`-templates
`-webapp
`-WEB-INF
`-home.jsp
The controller is plain simple.
@Controller
public class ViewMaster {
@RequestMapping("/home")
public String home() {
return "home";
}
}
Without any configuration, I'd like to know where Spring Boot expects the views to be stored and with what extension (html?). I've also tried to include the following in application.properties
but I still get a 404 error. Moving the WEB-INF directory or just the html file around in resources didn't help either.
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
I've also tried including these dependencies in my pom.xml without any effect.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
I must be missing something painfully obvious here so appreciate if someone can point that out!
.jsp
files under your/WEB-INF/
directory. I see onlyhome.html
file, is that a jsp file and a typo error in question? – ChockWEB_INF
directory supposed to only hold hidden views? – Buy