Spring 3.0 REST implementation DispatcherServlet cannot find mapping

I'm trying to get a simple REST service to work with Spring 3.0, but keep stumbling upon a blocking error:

No mapping was found for the HTTP request with the URI [/ travel / us / nyc / sfo / 20091010/1122 / true /] in the DispatcherServlet named 'dispatcher' *

However, the log file also states:

org.springframework.web.servlet.mvc.annotation.Def aultAnnotationHandlerMapping - URL of the associated URL [/ travel / us / {from} / {to} / {date} / {time} / {departure} /] handler [ experiment.SomeController@dd9f85 ] *

which I read as an indication that there is a mapping from the URI to the experiment. The SomeController class as a handler.

I should be missing a simple error in one of the configuration files, but having checked everything several times and doing quite a lot of Googling, I have not yet found a solution. I have already enabled registration for Spring classes, but this also did not reveal a problem.

Below are the relevant configuration files and some code snippets, any help can be used. Webapp is deployed in Glassfish v2.1, and I am using the M3 Spring 3.0.0 build on JDK1.5 on OS X.

The goal is for getTripDetails () to return the XML version of tripdetails. Hence the use of MarshallingView.

From web.xml:

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

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

dispatcher-servlet.xml:

<context:annotation-config />
<context:component-scan base-package="net.vermaas.reisadvies.server" />

<bean class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping">
<property name="alwaysUseFullPath" value="true"/>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.Conten tNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNa meViewResolver"/>
<bean class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
</bean>

<bean id="marshaller" class="org.springframework.oxm.xstream.XStreamMars haller">
</bean>

<bean id="content" class="org.springframework.web.servlet.view.xml.Ma rshallingView">
<property name="contentType" value="application/xml" />
<property name="marshaller" ref="marshaller"/>
</bean>

: @Controller public class SomeController {

static Logger logger = Logger.getLogger(SomeController.class);

public SomeController() { }

@RequestMapping(value="/travel/us/{from}/{to}/{date}/{time}/{departure}", method=RequestMethod.GET)

public ModelAndView getTripDetails(@PathVariable String from, @PathVariable String to, @PathVariable String date, @PathVariable String time, @PathVariable boolean departure, Model model) {

logger.debug("getTripDetails"); // not logged

// Do some stuff
TripDetails td = ...

ModelAndView mav = new ModelAndView();
mav.setViewName("content");
mav.addObject("tripDetails", td);

return mav;

}

}

>

, ? REST Spring 3.0, XML ?

,

+3
2

, , Spring 3.0, - /* url-pattern /

+2

- :

<servlet-mapping>
    <servlet-name>baseproj</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

css, js . , , . http://localhost:8080/myapp/rest apache mod_jk, .

+2

Source: https://habr.com/ru/post/1709710/


All Articles