Spring MVC: How to return image in @ResponseBody?
20 10 | I'm getting image data (as EDIT I did it without
Using
| |||
6 | In addition to registering a registerByteArrayHttpMessageConverter, you may want to use a ResponseEntity instead of @ResponseBody. The following code works for me :
| ||
4 | In your application context declare a AnnotationMethodHandlerAdapter and registerByteArrayHttpMessageConverter:
also in the handler method set appropriate content type for your response. | ||||||
|
2 | By using Spring 3.1.x and 3.2.x, this is how you should do it: The controller method:
And the mvc annotation in servlet-context.xml file:
| ||
0 | if you are using Spring version of 3.1 or newer you can specify "produces" in
|
출처 - http://stackoverflow.com/questions/5690228/spring-mvc-how-to-return-image-in-responsebody
'Framework & Platform > Spring' 카테고리의 다른 글
spring - 폼 태그(form tag) (0) | 2013.06.21 |
---|---|
spring - @RequestMapping produces consumes (0) | 2013.06.19 |
spring - ContentNegotiatingViewResolver 확장자로 mediaType 설정 (0) | 2013.06.12 |
spring data - mongodb @DBRef (0) | 2013.06.12 |
spring - @EnableTransactionManagement (0) | 2013.06.10 |