I am setting up a simple app with springMVC and getting following error:
I am using spring-framework-3.0.1.Code:org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/springapp/helloworld] in DispatcherServlet with name 'springapp'
Following is my directory structure:
This is what i have in web.xmlCode:├── build.properties ├── build.xml ├── src │** └── springapp │** └── web │** └── HelloWorldController.java └── war ├── helloWorld.jsp ├── index.jsp └── WEB-INF ├── classes │** └── springapp │** └── web │** └── HelloWorldController.class ├── jsp │** ├── hello.jsp │** └── helloWorld.jsp ├── lib ├── springapp-servlet.xml └── web.xml
This is what i have in spring-servlet.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > <servlet> <servlet-name>springapp</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springapp</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file> index.jsp </welcome-file> </welcome-file-list> </web-app>
Contents of src/springapp/web/HelloWorldController.javaCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="springapp.web.HelloWorldController" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
Any help?Code:package springapp.web; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class HelloWorldController { @RequestMapping("/springapp/hello") //@RequestMapping(value = "/helloWorld") public ModelAndView helloWorld() { String message = "Hello World, Spring 3.0!"; return new ModelAndView("helloWorld", "message", message); }


Reply With Quote