I'm working on a java spring mvc application. I have a method in my controller that responsible for producing image:
@RequestMapping(value = "/view", method = RequestMethod.GET, produces = "image/jpg")
public void viewImage(HttpServletResponse response, HttpServletRequest request) throws Exception
This works fine. But I have a problem now. The produced images may have 3 formats jpg, jpeg and png. Therefore I need several produces
attribute in the @RequestMapping
. Is there any way to do this? For example, something like this: produces = "image/jpg, image/jpeg, image/png"
You can have multiple mime types in produces, something like
produces={"image/jpg, image/jpeg, image/png"}
Now in order for the framework to know to which mimeType to resolve, you need to either add a Path or Parameter, or Accept header to the request (the so called PPA strategy). Read more at content negotiation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With