Tim McGinnis
Tim McGinnis

Reputation: 93

ExtJS 4 File Upload and Spring Error

I am trying to upload a file using extjs 4 and Spring 3.1. The file uploads properly but I keep getting errors on the response. Initially the error was:

Ext.Error: You're trying to decode an invalid JSON String:

{"success":true,"msg":"The upload was successful"}

So after researching I saw it said the response content-type should be text/html. I changed my controller to send text/html using the produces tag in the @RequestMapping annotation. Now I get a Http Error 406. But looking at the Accept headers the browser should be able to accept text/html.

http://localhost:9081/gppRenewalQuestionnaire/uploadExpenditure.htm

POST /gppRenewalQuestionnaire/uploadExpenditure.htm HTTP/1.1
Host: localhost:9081
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://localhost:9081/gppRenewalQuestionnaire/index.htm?nanda=C37843
Cookie: JSESSIONID=0000a7q2lUHepKNFfO__YaUIAZ-:-1
Content-Type: multipart/form-data; boundary=---------------------------23281168279961
Content-Length: 16056
-----------------------------23281168279961
Content-Disposition: form-data; name="owner"

772
-----------------------------23281168279961
Content-Disposition: form-data; name="rq"

439
-----------------------------23281168279961
Content-Disposition: form-data; name="fileData"; filename="GIGNotes.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

PK
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Date: Mon, 14 Jan 2013 14:26:46 GMT
Server: WebSphere Application Server/6.1
----------------------------------------------------------

Anybody have any ideas?

Upvotes: 0

Views: 425

Answers (1)

Tim McGinnis
Tim McGinnis

Reputation: 93

Sorry folks. A colleague looked at this issue for about 20 minutes and solved it. He said I didn't have the @ResponseBody annotation on the controller method that was processing the upload. I believe I did but I can't prove that. Oh well, it is working and that's what counts. :-)

Upvotes: 0

Related Questions