Reputation: 27
I am trying to develop my first spring mvc application and get the above error. I search dozen of solution of same exception but can not find any solution.
here is my web.xml
<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>
mvc-dispatcher-servlet.xml file
<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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="m"/>
<mvc:default-servlet-handler />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/Hello.ds">
NAME : <input type="text" name="hello">
<input type="submit" value="OK">
</form>
</body>
</html>
Controller
@org.springframework.stereotype.Controller
public class jnk {
@RequestMapping("/Hello")
public ModelAndView handleRequest(HttpServletRequest r,HttpServletResponse res) throws Exception{
String name=r.getParameter("name");
ModelAndView m=new ModelAndView("success");
m.addObject("MSG", name);
return m;
}
}
My jsp files are reside under WEB-INF/ directory
the package name is : m
Upvotes: 0
Views: 146
Reputation: 48015
The controller exposes a mapping named /Hello
(see: @RequestMapping("/Hello")
) but your form is attempting to submit to /Hello.ds
(see <form action="/Hello.ds">
).
Upvotes: 1