Spring MVC gives HTTP 406 for application/octet-stream -


i using spring web mvc , have written controller shall return binary data plugin in web-page show 3d content. plugin uses stk files it's models, have set-up webapp produce kind of contents *.stk urls

the springdispatcherservlet setup handle *.stk requests in web.xml

<servlet-mapping>     <servlet-name>springdispatcherservlet</servlet-name>     <url-pattern>*.stk</url-pattern> </servlet-mapping> 

my controller looks this:

@controller @requestmapping(value="/3dobject", produces="application/octet-stream") public class object3dcontroller {      @autowired     private designerservice designerservice;      @requestmapping(value="/{article}.stk", method=requestmethod.get, headers="accept: application/octet-stream")     public void getobject3dforarticle(httpservletresponse response, @pathvariable string article) throws ioexception {         response.setcontenttype("application/octet-stream");         object3d object = designerservice.get3dmodelforarticlenumber(article, languagecode.norwegian);         byte[] content = object.getcontent();         response.setcontentlength(content.length);         ioutils.write(content, response.getoutputstream());     } } 

when try access data through browser, following error:

http status 406 - resource identified request capable of generating responses characteristics not acceptable according request "accept" headers.

i have deployed app tomcat server on localhost.

any ideas of must make browser download binary data?

ps! changed *.3do (3d object) *.stk. 3do worked expected, plugin fails error (which hard interpret), have experiment in order verify wether or not url extension matters...

the requestmapping.produces() narrows request , therefore is

only mapped if accept matches 1 of these media types

so need set corresponding accept header in request plugin. cannot done making http request typing in url browser. 1 plugin find useful chrome advanced rest client. there plenty of others offer similar functionality. alternatively try using curl make request correct header.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -