No mapping found for HTTP request with URI [/demoApp/index.jsp] in DispatcherServlet with name 'newApp'
I am getting this error please help.I am using Tomcat v9.0 server.
index.jsp
<html>
<body>
<form action="add">
<input type="text" name="t1"><br>
<input type="text" name="t2"><br>
<input type="submit"><br>
</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>newApp</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>newApp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
newApp-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 ">
<mvc:annotation-driven />
<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package="com.newApp"></ctx:component-scan>
</beans>
AddController.java
package com.newApp;
import java.lang.*;
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 good");
}
}
program should print "I am good" on the console but it is showing error on browser "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." on the console it is showing "No mapping found for HTTP request with URI [/demoApp/add] in DispatcherServlet with name 'newApp'".
This error accures when i click on submit button on jsp page.