java - Force Download CSV from Spring Controller -



java - Force Download CSV from Spring Controller -

follow question last issue has since been resolved.

i'm trying download file via spring @controller returning filesystemresource. receive valid http 200 response , can view of file's content in browser, never receive prompt download file. here's method:

@requestmapping(method = requestmethod.get, headers="accept=*/*", value = "/download/{filename:.+}", produces = mediatype.application_octet_stream_value) @responsebody public filesystemresource download(@pathvariable string filename, httpservletresponse response) throws ioexception { file file = new file(path + '/' + filename); response.setcontentlength((int)filename.length()); response.setcontenttype("application/force-download"); response.setheader("content-disposition","attachment; filename=\"" + filename + "\"");//filename); homecoming new filesystemresource(file); }

from browser:

response headers content-disposition | attachment; filename="my_data.csv" content-length | 1712 content-type | text/csv request headers take | */* accept-encoding | gzip, deflate accept-language | en-us,en;q=0.5

everything appears valid here; thought why actual file isn't getting returned? cheers

for download: use:

response.setcontenttype("application/octet-stream");

note result "content-type | text/csv" doesn't match set

java spring

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -