I checked my code so many times and also I read a lot of articles but wasn't able to correct my errors.My index.jsp is running fine but as i am calling my controller AddController file (on click of submit button in index.jsp) i am getting an error message: No mapping found for HTTP request with URI [/SpringMVC/add1] in DispatcherServlet with name 'ajit'
Here is the code: 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>ajit</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ajit</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
ajit.servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package="com.ajit"></ctx:component-scan>
</beans>
AddController
package com.ajit;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class AddController {
@RequestMapping("/add1")
public void add() {
System.out.println("Hello how are you");
}
}
Web Pages/index.jsp:
<%@page import="jdk.internal.misc.FileSystemOption"%>
<html>
<head>
<link rel="shortcut icon" href="http://example.com/favicon.ico">
</head>
<body>
<form action="add1">
<%
System.out.println("Hello ooo");
%>
<input type="text" name="t1"/></br>
<input type="text" name="t2"/></br>
<input type="submit"/>
</form>
</body>
</html>