I have a project provide rest service api for client ...
1. upload image, via image/add.xml or image/add.json to server, return xml or json text(include the new image id).
2. get image via image/{id} with a optional format , eg image/{id}.jpg return a jpg stream(the service convert image format when uploaded), if not specify a format, return the uploaded original format...
Now the problem is ....
I define three HttpMessageConverter, in spring config file...
I define a rest template in a test context file, and use the restTemplate to test the service.HTML Code:<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <util:list id="beanList"> <ref bean="bufferedImageHttpMessageConverter"/> <ref bean="marshallingHttpMessageConverter"/> <ref bean="jsonHttpMessageConverter"/> </util:list> </property> </bean>
The result is .
1. upload file works well.
2. But it is strange for fetch image...It throw a org.codehaus.jackson.map.JsonMappingException: exception....
the get image code is like the following
What is wrong? It seems lke it use the JSON converter to convert BufferedImage the response body...PHP Code:@RequestMapping(method = RequestMethod.GET, value = {"{id}.png", "{id}.gif", "{id}.jpg", "{id}"})
@ResponseBody
public BufferedImage get(@PathVariable Long id,
@RequestParam(value = "width", required = false) Integer width,
@RequestParam(value = "height", required = false) Integer height,
ModelMap modelMap,
HttpServletRequest request,
HttpServletResponse response) {
log.debug(">>>call get method <<<<");
log.debug("request paramenters@width =" + width + ",height=" + height);
.......
return bImage;
}
How do fix this problem...
I used the Spring roo to generate the project structure....most of config is use the default...


Reply With Quote