Tuesday 15 April 2014

configuration - Simple spring application does not start (mapping problems) -


I have problems with spring applications I'm trying to make app very easy.

web.xml

  & lt; Web-App version = "3.0" xmlns = "http: //java.sun .com / xml / ns / javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema -instance" xsi: Schema Location = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd"> & Lt; Servlet & gt; & Lt; Servlet-name & gt; MVC-Despatcher & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Org.springframework.web.servlet.DispatcherServlet & lt; / Servlet category & gt; & Lt; Load-On-Startup & gt; 1 & lt; / Load-on-startup & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; MVC-Despatcher & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / * & Lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; & Lt; Context param & gt; & Lt; Ultimate Name & gt; ContextConfigLocation & lt; / Lastname & gt; & Lt; Ultimate Price & gt; /WEB-INF/mvc-dispatcher-servlet.xml< / Super-valued & gt; & Lt; / Reference param & gt; & Lt; Listener & gt; & Lt; Audience category & gt; Org.springframework.web.context.ContextLoaderListener & lt; / Audience & gt; & Lt; / Listener & gt; & Lt; / Web application & gt;   

mvc-dispatcher-servlet.xml

  & lt; Bem xmlns = "http://www.springframework.org/schema/beans" xmlns: Xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: reference = "http: // www. Springframework.org/schema/context "xmlns: mvc =" http: //www.springframework .org / schema / mvc "xsi: schema location =" http://www.springframework.org/schema/beans http: // Www.springframework.org/schema/beans/spring-beans.xsd http: // www. Springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http: / /www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> & Lt; Reference: component-scan base-package = "com.controller" /> & Lt; Reference: Annotation-config / & gt; & Lt; MVC: annotation driven /> & Lt; Bean square = "org.springframework.web.servlet.view.InternalResourceViewResolver" & gt; & Lt; Property name = "prefix" value = "/ web-nf / page /" /> & lt; Property name = "suffix" value = ".jsp" /> & Lt; / Bean & gt; & Lt; / Bean & gt;   

Main Controller

  Package com.controller; Import org.springframework.stereotype.Controller; Import org.springframework.web.bind.annotation.RequestMapping; @ Controller Public Class Chief Controller {@RequestMapping ("/") Public String Index () {Return "Index"; }}   

index.jsp

  & lt;% @ page content type = "text / html; charset = utf-8"%> & Lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Some pages & lt; / Title & gt; & Lt; Jsp: include = "parts / head. Jsp" /> & Lt; / Head & gt; & Lt; Body & gt; & Lt; Jsp: Include Page = "Parts / Header .jsp" /> & Lt; Section role = "main" & gt; Hello. This will be the main page. & Lt; / Section & gt; & Lt; Jsp: include page = "parts / footer.jsp" /> & Lt; / Body & gt; & Lt; / Html & gt;   

So ... all look good ... but there is a problem. I am starting this app and log:

  information: map "{[/], methods = [], parameters = [], header = [], consumption = [], output Does [], custom = []} "public java.lang.String com.controller.MainController.index () on alert: with the name URI in DispatcherServlet [/WEB-INF/pages/index.jsp] with HTTP No mapping was found for request 'MVC-Dispatcher' June 23, 2013 12:37:49 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound   

Therefore. Tomcat found the controller, executed it, saw it (page) and ... it did not get mapping (page). Where is my fault Thanks for your reply

Change this:

  & lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Despatcher & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / * & Lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;   

To do this:

  & lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Despatcher & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / & Lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;    

No comments:

Post a Comment