tomcat - "Hello world" tutorial error -


i'm following this tutorial , ran following error:

> jul 19, 2013 2:18:14 pm > org.springframework.web.servlet.dispatcherservlet nohandlerfound > warning: no mapping found http request uri > [/spring3mvc/hello.html] in dispatcherservlet name 'spring' 

i can open first jsp file (index.jsp), when click on "say hello" shows 404 me. tried methods suggested in comments of tutorial, didn't work.

the place deviated tutorial use tomcat 7 instead of 6. else looks same using eclipse. code same in tutorial, no need paste here right now. :)

the hello.jsp file path is:

spring3mvc\webcontent\web-inf\jsp\hello.jsp 

web.xml is:

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"     xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"     id="webapp_id" version="2.5">     <display-name>spring3mvc</display-name>     <welcome-file-list>         <welcome-file>index.jsp</welcome-file>     </welcome-file-list>      <servlet>         <servlet-name>spring</servlet-name>         <servlet-class>             org.springframework.web.servlet.dispatcherservlet         </servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>spring</servlet-name>         <url-pattern>*.html</url-pattern>     </servlet-mapping> </web-app> 

spring-servlet.xml file:

<?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"     xmlns:mvc="http://www.springframework.org/schema/mvc"     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="net.viralpatel.spring3.controller" />      <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> 

controller.java

package net.viralpatel.spring3.controller;  import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.servlet.modelandview;  @controller public class helloworldcontroller {      @requestmapping("/hello.html")     public modelandview helloworld() {          string message = "hello world, spring 3.0!";         return new modelandview("hello", "message", message);     } } 

tomcatlog:

jul 19, 2013 3:25:00 pm org.apache.catalina.core.aprlifecyclelistener init info: apr based apache tomcat native library allows optimal performance in production environments not found on java.library.path: c:\program files\java\jre7\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:\python27;c:\cloudbees-sdk-1.5.0;c:\python27\scripts;c:\eclipse\sdk\adt-bundle-windows-x86_64-20130522\sdk\platform-tools;c:\tomcat 7.0.12;c:\windows\system32;c:\program files (x86)\google\google_appengine\;. jul 19, 2013 3:25:00 pm org.apache.tomcat.util.digester.setpropertiesrule begin warning: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.jee.server:spring3mvc' did not find matching property. jul 19, 2013 3:25:00 pm org.apache.coyote.abstractprotocol init info: initializing protocolhandler ["http-bio-8080"] jul 19, 2013 3:25:00 pm org.apache.coyote.abstractprotocol init info: initializing protocolhandler ["ajp-bio-8009"] jul 19, 2013 3:25:00 pm org.apache.catalina.startup.catalina load info: initialization processed in 834 ms jul 19, 2013 3:25:00 pm org.apache.catalina.core.standardservice startinternal info: starting service catalina jul 19, 2013 3:25:00 pm org.apache.catalina.core.standardengine startinternal info: starting servlet engine: apache tomcat/7.0.42 jul 19, 2013 3:25:02 pm org.apache.catalina.core.applicationcontext log info: initializing spring frameworkservlet 'spring' jul 19, 2013 3:25:02 pm org.springframework.web.servlet.frameworkservlet initservletbean info: frameworkservlet 'spring': initialization started jul 19, 2013 3:25:02 pm org.springframework.context.support.abstractapplicationcontext preparerefresh info: refreshing webapplicationcontext namespace 'spring-servlet': startup date [fri jul 19 15:25:02 eest 2013]; root of context hierarchy jul 19, 2013 3:25:02 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions info: loading xml bean definitions servletcontext resource [/web-inf/spring-servlet.xml] jul 19, 2013 3:25:02 pm org.springframework.beans.factory.support.defaultlistablebeanfactory preinstantiatesingletons info: pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@44dc42ab: defining beans [org.springframework.context.annotation.internalconfigurationannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,org.springframework.context.annotation.internalcommonannotationprocessor,viewresolver]; root of factory hierarchy jul 19, 2013 3:25:02 pm org.springframework.web.servlet.frameworkservlet initservletbean info: frameworkservlet 'spring': initialization completed in 628 ms jul 19, 2013 3:25:02 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["http-bio-8080"] jul 19, 2013 3:25:02 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["ajp-bio-8009"] jul 19, 2013 3:25:02 pm org.apache.catalina.startup.catalina start info: server startup in 1982 ms jul 19, 2013 3:25:05 pm org.springframework.web.servlet.dispatcherservlet nohandlerfound warning: no mapping found http request uri [/spring3mvc/hello.html] in dispatcherservlet name 'spring' jul 19, 2013 3:35:54 pm org.springframework.web.servlet.dispatcherservlet nohandlerfound warning: no mapping found http request uri [/spring3mvc/hello.html] in dispatcherservlet name 'spring' 

(ps! maybe can point me working tutorial well)

your file named sprint-servlet.xml? maybe that's problem.

as sotirios delimanolis pointed out, it's supposed named after tag, default.

the name of file should spring-servlet.xml.

an example of spring application here.

an official spring tutorial here.


Comments