java - WARNING: No mapping found for HTTP request with URI [/Spring3MVC/hello.html] in DispatcherServlet with name 'spring' -


why happening.

"warning: no mapping found http request uri [/spring3mvc/hello.html] in dispatcherservlet name 'spring' " 

my 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 is

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

index.jsp is

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body>     <a href="hello.html">say hello</a> </body> </html> 

hello.jsp is

<html> <body>     <h1>message : ${message}</h1>    </body> </html> 

helloworldcontroller.java is

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")     public modelandview helloworld() {          string message = "hello world, spring 3.0!";         return new modelandview("hello", "message", message);     } } 

why above warning comming , not hitting controller.

org.springframework.web.servlet.dispatcherservlet nohandlerfound warning: no mapping found http request uri [/spring3mvc/hello.html] in dispatcherservlet name 'spring'. 

try add <mvc:annotation-driven />.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -