java - Getting .servlet.DispatcherServlet noHandlerFound -


i trying learn this tutorial how write rest api. supposed replace ${msg} inside index.jsp file message.

the problem when try call servlet @ http://localhost:8080/mahlzeitserver/helloworld/hello getting response tomcat:

http status 404 - /mahlzeitserver/web-inf/helloworld.jsp  type:        status report message:     /mahlzeitserver/web-inf/helloworld.jsp description: requested resource not available. 

i'm note sure why case. if go localhost:8080/mahlzeitserver site gets displayed ${msg} not replaced. here index.jsp file:

<html> <body> <h2>hello world2!</h2> <h3>your message : ${msg}</h3>   </body> </html> 

helloworldcontroller.java

package com.mahlzeit.server;  import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.pathvariable; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod;  @controller @requestmapping("/helloworld") public class helloworldcontroller {      @requestmapping(value = "/hello", method = requestmethod.get)     public string hello(modelmap model) {         model.addattribute("msg", "jcg hello world!");         return "helloworld";     }      @requestmapping(value = "/displaymessage/{msg}", method = requestmethod.get)     public string displaymessage(@pathvariable string msg, modelmap model) {         model.addattribute("msg", msg);         return "helloworld";     } } 

mvc-dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     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 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">      <!-- changed <context:component-scan base-package="com.javacodegeeks.snippets.enterprise" />-->     <context:component-scan base-package="com.mahlzeit.server" />      <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">         <property name="prefix">             <value>/web-inf/</value>         </property>         <property name="suffix">             <value>.jsp</value>         </property>     </bean> </beans> 

web.xml

<!doctype web-app public  "-//sun microsystems, inc.//dtd web application 2.3//en"  "http://java.sun.com/dtd/web-app_2_3.dtd" >  <web-app>     <display-name>archetype created web application</display-name>       <servlet>         <servlet-name>mvc-dispatcher</servlet-name>         <servlet-class>             org.springframework.web.servlet.dispatcherservlet         </servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>mvc-dispatcher</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping>  </web-app> 

looks case issue. try

@controller @requestmapping("/helloworld") public class helloworldcontroller { ... 

instead of

@controller @requestmapping("/helloworld") public class helloworldcontroller { 

or try hitting

http://localhost:8080/mahlzeitserver/helloworld/hello 

instead of

http://localhost:8080/mahlzeitserver/helloworld/hello 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -