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:
KTDispatcher-servlet.xmlpackage 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";
}
}
web.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>
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.<?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>
Can someone please tell me where i am going wrong?WARNING: No mapping found for HTTP request with URI [/KT-App/home/home] in DispatcherServlet with name 'KTDispatcher'


Reply With Quote