I have written a Spring MVC application which displays report of Test cases and suites run in XML view.I have written the model class which is fine and I have written the following files but there’s some problem with Handler Mapping i guess
My controller.java class looks like this
package com.DrAssist.Fitnesse.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.DrAssist.Fitnesse.model.Suite;
@Controller
@RequestMapping("/Suite/{name}")
public class XMLController {
@RequestMapping(value="{name}", method = RequestMethod.GET, headers = "content-type=application/xml")
public @ResponseBody Suite getSuiteInXML(@PathVariable String name) {
Suite suite = new Suite("1",name,"3","Test1","4","5","7","9","550");
return suite;
}
}
My web.xml file looks like this
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring Web MVC Application</display-name>
<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>
</web-app>
and dispatcher-servlet.xml file looks like this
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.DrAssist.Fitnesse.controller" />
<mvc:annotation-driven />
<!--
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
<bean id="xmlViewer"
class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg>
<bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.DrAssist.Fitnesse.model</value>
</list>
</property>
</bean>
</constructor-arg>
</bean>
-->
</beans>
I am getting a 404 error with console showing error as
No mapping found for HTTP request with URI [/SpringMVC/Suite/suite1] in DispatcherServlet with name ‘mvc-dispatcher’
Please advice It seems the request not getting through from SpringMVC part of /SpringMVC/Suite/suite1] itself.
Thanks in advance
You put
{name}path variable in both@RequestMapping. Try to leave the first just as@RequestMapping("Suite").