Announcement Announcement Module
Collapse
No announcement yet.
No mapping found for HTTP request with URI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No mapping found for HTTP request with URI

    I am trying out Spring 3.0 with annotations and am not able to access the Application using the URL

    http://localhost:8080/KT-App/home

    Following are the configurations i am using

    Controller:
    package com.igate.kt.web.controller;

    import java.util.Map;

    import javax.inject.Inject;

    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMap ping;
    import org.springframework.web.portlet.bind.annotation.Re nderMapping;

    import com.igate.kt.service.KTHomepageService;

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

    KTHomepageService homapageService = null;

    @Inject
    public KTHomepageController(KTHomepageService homepageService)
    {
    this.homapageService = homepageService;
    }

    @RenderMapping (value="/")
    public String displayHomepage(Map<String, Object> model)
    {
    model.put("EXAMPLE_TEXT", "THIS IS HOME PAGE");

    return "homepage";
    }

    }
    KTDispatcher-servlet.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc
    http://www.springframework.org/schem...ng-mvc-3.0.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <mvc:resources location="/static/" mapping="/static/**"/>

    <mvc:annotation-driven/>

    <context:component-scan base-package="com.igate.kt"/>

    <bean class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew"/>
    <property name="prefix" value="/jsp/"/>
    <property name="suffix" value=".jsp"/>
    </bean>

    </beans>
    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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">

    <display-name>Knowledge Transition Application</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
    <servlet-name>KTDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>KTDispatcher</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>
    </web-app>
    According to the documentation and the posts i am reading, it seems that this configuration should work. However, this is not working and when i try accessing the URL, i get the a 404 error, and the error on the console is.

    WARNING: No mapping found for HTTP request with URI [/KT-App/home/home] in DispatcherServlet with name 'KTDispatcher'
    Can someone please tell me where i am going wrong?

  • #2
    Hi,
    try setting:

    Code:
    @RequestMapping (value="/home/index")
    public String displayHomepage(Map<String, Object> model)
    {
    model.put("EXAMPLE_TEXT", "THIS IS HOME PAGE");
    
    return "homepage";
    }
    And remove the requestMapping at the controller class. See if it works. If not come back here..

    Comment


    • #3
      Hi johanneshiemer,

      I got the error i was making in my code. If you see the annotation around the method, its is @RenderMapping instead of @RequestMapping. i made this change and it started to work.

      Thanks a lot for your response.

      Comment

      Working...
      X