java - Tomcat returns a 404 page using Spring MVC; controller not reached -


i have controller , jsp. all. export project .war , put in tomcat webapps directory running on linux mint. when type localhost:8080/filename address bar, returns tomcat 404 message.

controller:

package web.controllers;  import java.util.random;  import org.springframework.stereotype.controller; import org.springframework.ui.model; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod;  @controller @requestmapping(value = "/") public class homecontroller  {      @requestmapping(method = requestmethod.get)     public string displayhomepage(model model)      {         model.addattribute("display",new random().nextint());         return "/index";     } } 

index.jsp:

<%@ page contenttype="text/html" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>insert title here</title> </head> <body> <p>random int: ${display}</p> </body> </html> 

the jsp file in web-inf folder under webcontent (the default eclipse dynamic webapps project setup). spring jars referenced project , there no compile errors. missing here?

have configured view resolver? infers view, jsp file, return value e.g. "index".

if using spring boot, putting couple of lines in application.properties that. example, in 1 of projects, put jsps inside web-inf/jsp folder, , have these couple of lines in application.properties:

spring.view.prefix: /web-inf/jsp/ spring.view.suffix: .jsp 

then returning "index" (no beginning slash) web-inf/jsp/index.html.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -