2

I am using pre setup Maven project from openshift and when I`m running the app on Tomcat the answer is "HTTP Status 404 - /WEB-INF/views/hello.jsp" Here is the web.xml

<display-name>Spring MVC Application</display-name> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> 

dispatcher-servlet

<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> 

hello.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title></title> </head> <body> <h1>Message : ${message}</h1> </body> </html> 

and controller

@Controller @RequestMapping("/welcome") public class Test { @RequestMapping(method = RequestMethod.GET) public String printWelcome(ModelMap model) { model.addAttribute("message", "Spring 3 MVC - Hello World"); return "hello"; } } 

My IDEA Spring service shows that it is not able to resolve "hello" in "return "hello";" and there is no error in log just shows "HTTP Status 404 - /WEB-INF/views/hello.jsp" when i ask for http://localhost:9999/welcome; Appreciate everyone`s answer

PS here is the source code if anyone is interested, thanks

6
  • please add the error or exception logs. Commented Oct 23, 2015 at 15:05
  • Well, there is no error in log just shows "HTTP Status 404 - /WEB-INF/views/hello.jsp" when i ask for localhost:9999/welcome. the server starts just fine Commented Oct 23, 2015 at 15:08
  • 2
    Provide context name in URL (localhost:9999/yourProjectName/welcome) and hit again. Commented Oct 23, 2015 at 15:25
  • Thank you, already tried, does not help. Added source from github Commented Oct 23, 2015 at 15:37
  • BTW localhost:9999/restauranter/welcome shows HTTP Status 404 only without /WEB-INF/views/hello.jsp. which means controller works.... probably Commented Oct 23, 2015 at 15:56

1 Answer 1

2

In the view resolver you are pointing to /WEB-INF/views instead use value="/WEB-INF/pages/" Then hello.jsp should shows up.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.