1
votes

I'm just trying out a sample that gave the above error message

21 Dec, 2011 12:14:46 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/BOL/home] in DispatcherServlet with name 'mvc-dispatcher'

Following is the code

package in.kukku.bol.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/home")
public class Home {

@RequestMapping(method = RequestMethod.GET)
public String printMsg(ModelMap model) {
    model.addAttribute("msg", "hi");
    return "index";
    }
}

mvc-dispatcher servlet

<context:component-scan base-package="in.kukku.bol.controller" />

<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>

web.xml

<servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</context-param>

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

Can you tell me where I'm wrong

2

2 Answers

0
votes

It seems you are trying to access application at /BOL URL for this you haven't defined the controller, try to access it with {APP_CONTEXT}/home

0
votes

I added request mapping url format to methods. Then I altered web.xml file and it started working.