I am a spring beginner, I used controller and request mapping to go to some java file from index.jsp but its showing 404 Error. I am putting right urlmapping and requestmapping and controllers as I saw in a spring tutorial. I have tried including more dependencies, changing the code as I saw someplace else, but nothing working. Please help me with this code. Thanks in Advance
index.jsp:
<html>
<body>
<form action="add">
<input type="text" name="t1"><br>
<input type="text" name="t2"><br>
<input type="submit">
</form>
</body>
</html>
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>bhoomika</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>bhoomika</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
bhoomika-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="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-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">
<context:annotation-config></context:annotation-config>
<context:component-scan base-package="garg.bhoomika"></context:component-
scan>
</beans>
AddController.java
package garg.bhoomika;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class AddController
{
@RequestMapping("/add")
public void add()
{
System.out.println("I am here");
}
}
Error:
org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/SpringMVC/add] in DispatcherServlet with name 'bhoomika'