File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Defaulting Request Header in REST service using spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Defaulting Request Header in REST service using spring" Watch "Defaulting Request Header in REST service using spring" New topic
Author

Defaulting Request Header in REST service using spring

Ganesh Kumar C V
Greenhorn

Joined: May 12, 2011
Posts: 5
Hi - I have a controller which handles all the requests to a set of REST services. For one of the services, I defined the @RequestMapping like the below and its working fine.
@RequestMapping(value = "NetworkOrder/Note",
method = RequestMethod.GET,
headers="X-YY-Version=1.0")

The issue is that I need to default the value of this header 'X-YY-Version' to some value if the request does not contain this header set. Also the service should not complaint if the value is not available in the request. Right now I am getting the below exception if the header is not available in the request. Any help will be very useful.

<html><head><title>Apache Tomcat/7.0.11 - Error report</title><style>
</u></p><p><b>exception</b>
-----
-----
<pre>org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException: No matching handler method found for servlet request: path '/ServiceDelivery/Order/CustomerOrder/Note', method 'GET', parameters map['serviceOrderVersion' -> array<String>['100'], 'serviceOrderId' -> array<String>['1-HQRGH']]
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:646)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:431)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:575)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)




Thanks
Ganesh
 
 
subject: Defaulting Request Header in REST service using spring
 
Similar Threads
MySQL
Error is Spring MVC - items should be Map, Array or a collection.
org.springframework.web.HttpSessionRequiredException: Session attribute 'user' required - not found
Integrating hibernate with spring
Not able to render view in Spring 2.5 with Tiles2