Up vote 1 down vote favorite share g+ share fb share tw.
I am trying to create and run a simple Spring 3.1 mvc web application where I have defined a controller that simply returns "hello" in the response body using the class below: package com.jr.freedom. Controllers; import org.springframework.stereotype. Controller; import org.springframework.web.bind.annotation.
RequestMapping; import org.springframework.web.bind.annotation. RequestMethod; import org.springframework.web.bind.annotation. ResponseBody; @Controller public class Hello { @RequestMapping(value = "/hello", method = RequestMethod.
GET) @ResponseBody public String helloWorldInJson() { return "hello"; } } I have tried this URL but I keeps returning a 404 error? http://localhost:8080/FreedomSpring/hello Here is my servlett: here is the web. Xml file FreedomSpring org.springframework.web.servlet.
DispatcherServlet 1 FreedomSpring *. Htm org.springframework.web.context. ContextLoaderListener contextConfigLocation log4jConfigLocation /WEB-INF/log4j.
Xml index. Jsp org.springframework.web.util. Log4jConfigListener And finally my mvc-config.
Xml I am using tomcat 7 on a windows 7 machine by the way. No errors are found from my logfile from tomcat: 13-Feb-2012 12:37:36 org.apache.catalina.core. ApplicationContext log INFO: Destroying Spring FrameworkServlet 'FreedomSpring' 13-Feb-2012 12:37:36 org.apache.catalina.core.
ApplicationContext log INFO: Shutting down log4j 13-Feb-2012 12:37:36 org.apache.catalina.core. ApplicationContext log INFO: Closing Spring root WebApplicationContext 13-Feb-2012 12:37:37 org.apache.catalina.core. ApplicationContext log INFO: Initializing Spring root WebApplicationContext 13-Feb-2012 12:37:37 org.apache.catalina.core.
ApplicationContext log INFO: Set web app root system property: 'webapp. Root' = C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\FreedomSpring\ 13-Feb-2012 12:37:37 org.apache.catalina.core. ApplicationContext log INFO: Initializing log4j from C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\FreedomSpring\WEB-INF\log4j.
Xml 13-Feb-2012 12:37:37 org.apache.catalina.core. ApplicationContext log INFO: Initializing Spring FrameworkServlet 'FreedomSpring' 0:0:0:0:0:0:0:1 - - 13/Feb/2012:12:37:45 +0000 "GET /FreedomSpring HTTP/1.1" 302 - 0:0:0:0:0:0:0:1 - - 13/Feb/2012:12:37:45 +0000 "GET /FreedomSpring/ HTTP/1.1" 404 997 0:0:0:0:0:0:0:1 - - 13/Feb/2012:12:37:51 +0000 "GET /FreedomSpring/hello HTTP/1.1" 404 1012 Any ideas? Spring tomcat spring-mvc link|improve this question asked Feb 13 at 12:46jonney707933 51% accept rate.
Your DispatcherServlet is mapped to *. Htm: FreedomSpring *. Htm But you are accessing the controller through non-matching URL: http://localhost:8080/FreedomSpring/hello.
You have three choices: Change you dispatcher servlet to: FreedomSpring /* but in this case all requests will be handled through the Spring MVC, including images and other static resources Use extension in controllers as well: /*. Htm and map htm so that you use: http://localhost:8080/FreedomSpring/hello.htm. Map controllers to a different subdirectory: /mvc/* to access them you will have to use: http://localhost:8080/FreedomSpring/mvc/hello without making any changes to the controller itself.
1 Brilliant thanks, you are a life saver – jonney Feb 13 at 14:03.
Looks like your Dispatcher servlet is filtering only the request matching *.htm. So I guess it's normal that http://localhost:8080/FreedomSpring/hello returns a 404.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.