WARNING: No mapping found for HTTP request with URI
Hi Team,
I'm new in the Spring world and I'm building my first Hello World, but things are not working well, would someone help me?
This is my Login.java
package com.managementtool7ul.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class Login {
@RequestMapping("/login")
public ModelAndView login() {
return new ModelAndView("index");
}
}
My managementtool7ul.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.managementtool7ul.controller" />
<!-- <mvc:default-servlet-handler/> -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>CrunchifySpringMVCTutorial</display-name>
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>managementtool7ul</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>managementtool7ul</servlet-name>
<url-pattern>*.jsp</url-pattern>
<!--
<url-pattern>/index.jsp</url-pattern>
<url-pattern>/welcome.html</url-pattern>
<url-pattern>*.html</url-pattern>
-->
</servlet-mapping>
</web-app>
This is the log:
Jul 14, 2017 2:44:49 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/managementtool7ul/] in DispatcherServlet with name 'managementtool7ul'
Jul 14, 2017 2:45:07 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/managementtool7ul/welcome.jsp] in DispatcherServlet with name 'managementtool7ul'
The files structure:
Let me know if anything else is needed.