No mapping found for HTTP request with uri in DispatcherServlet with name 'spring'



I am new to Spring framework. I m trying a very basic example. Here is my web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU" xmlns="http://ift.tt/nSRXKP" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP " id="WebApp_ID" version="3.0">
<display-name>MovieDB</display-name>
<servlet>
<servlet-name>movie-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>movie-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>


Here is my movie-dispatcher-servlet.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:context="http://ift.tt/GArMu7"
xmlns:p="http://ift.tt/1jdM0fE"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/GArMu6
http://ift.tt/1cnl1uo
http://ift.tt/GArMu7
http://ift.tt/1ldEMZY ">
<context:component-scan base-package="com.moviedb.controller" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>


Here is my controller



package com.moviedb.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class MovieDBController {
@RequestMapping("/homepage")
public ModelAndView getHomePage(){
ModelAndView model = new ModelAndView("homepage");
return model;
}
@RequestMapping("/movie")
public ModelAndView getMovieDetailsPage(){
//code
}
}


When I type this url in my browser http://localhost:8080/MovieDB/homepage


I'm getting a 404 error and



org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/MovieDB/homepage] in DispatcherServlet with name 'movie-dispatcher'



In my server console.


I am not able to figure out what is going wrong here


No comments:

Post a Comment