Question

I have a problem with method generating PNG image responses.

@RequestMapping(value = "/thumb/{id}.png", produces = "image/png")
@ResponseBody
public char[] thumb(@PathVariable UUID id)
{
    // action logic here

    return CatalogController.PLACEHOLDER_THUMB;
}

However I can't access this action - it is executed correctly (I see logic effects in database), but client gets 406 Not Acceptable.

Here is how I simulate the request (same happens in Chrome and Internet Explorer):

$ wget "http://localhost:8080/thumb/13164e6b-fc0f-4c67-a7d3-e2c56224384b.png" -O - --header="Accept: image/png"
--2013-11-18 18:37:30--  http://localhost:8080/thumb/13164e6b-fc0f-4c67-a7d3-e2c56224384b.png
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 406 Not Acceptable
2013-11-18 18:37:30 ERROR 406: Not Acceptable.

Edit

Here is more detailed description displayed in browser:

description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().

Was it helpful?

Solution

Ok, thanks for everyone for helping, but the answer is far more trivial - it's simply not possible to use char[] as response content.

Switched to byte[] and everything worked fine!

(probably could be possible to register handler for byte[] but it's not needed for me, so can't confirm that).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top