Reputation: 109
Got a simple project setup, my goal is to load a jsp file:
I got my Controller with a RequestMapping for a jsp file.
package com.example.registrationFrom.control;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class Control {
@RequestMapping("/")
public String home() {
System.out.println("Going home...");
return "index"; // name JSP file
}
}
application.properties with a directory to the jsp
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
A jsp file in the project directory:
src/main/webapp/WEB-INF/views/index.jsp
And I added the dependency (which is active)
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
When I run the code and check localhost:8080 I get a 404. I check the code a number of time but can't figure out why its not working. please check out my full code on github
Upvotes: 0
Views: 800
Reputation: 11
If you're using Eclipse...
Did you check server.xml?
i guess, maybe you should be check - this area
<Context docBase="helloworld" path="/testRoot" reloadable="true" .../>
TO
<Context docBase="helloworld" path="/" reloadable="true" .../>
Otherwise, if you're using a embeded-in tomcat of spring-boot, you should do maven clean and install. Because JSP is not static page (and not automatic load), so should be build again.
Upvotes: 1