Hi I am working on Spring MVC 4.0. When I try to access login page by URL http://localhost:8080/bookstore-web-0.0.1-SNAPSHOT/bookstore/authentication/login
, it shows 404 error. And logs shows below warning
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/bookstore-web-0.0.1-SNAPSHOT/bookstore/authentication/login] in DispatcherServlet with name 'appServlet']]
Here bookstore-web-0.0.1-SNAPSHOT
is my .war file.
I did following mapping in my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml, /WEB-INF/spring/appServlet/security-config.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/bookstore/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- Map all /resources requests to the Resource Servlet for handling -->
<!-- <servlet-mapping>
<servlet-name>Resources Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping> -->
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/bookstore/*</url-pattern>
</servlet-mapping>
Controller Is:
package com.abhendra.bookstore;
@Controller
public class AuthenticationController {
private static final Logger logger = LoggerFactory.getLogger(AuthenticationController.class);
/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/authentication/login", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
System.out.println("In Controller!!!!!!!!!!!!!!!!!!!!!!");
return "login";
}
}
I have also done component-scan entry in my root-context.xml file. like:
<context:component-scan base-package="com.abhendra.bookstore, com.abhendra.core" />
<context:annotation-config />
I am not getting where am I doing mistake.
Thanks In advance.