I am getting error in spriing No mapping found for HTTP request with URI
I know this question already have been asked, but for my error I referred those question even I did not got the solution for my error.
Error log
Jul 08, 2018 4:30:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'project'
Jul 08, 2018 4:30:51 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'project': initialization started
Jul 08, 2018 4:30:51 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'project-servlet': startup date [Sun Jul 08 16:30:51 IST 2018]; root of context hierarchy
Jul 08, 2018 4:30:51 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/project-servlet.xml]
Jul 08, 2018 4:30:52 PM org.springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler
INFO: Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0'
Jul 08, 2018 4:30:52 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'project': initialization completed in 806 ms
I am just trying to display Hello World from Controller.java when I clicked submit button from index.jsp
Error :
Jul 08, 2018 2:28:36 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/project/myMethod] in DispatcherServlet with name 'project'
Web Pages/index.jsp:
<html>
<body>
<form action="myMethod">
Username : <input name="un"><br/>
Password : <input name="pwd"><br/>
<input type="submit" value="Login">
</form>
</body>
</html>
Under
src/main/resources
com.project
Controll.java
package com.project;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class Controll {
@RequestMapping("/myMethod")
public void CtrlMethod() {
System.out.println("Hello World");
}
}
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>project</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>project</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
project-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-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 ">
<context:annotation-config />
<context:component-scan base-package="com.project"/>
</beans>