我正在尝试使用extjs 4和Spring 3.1上传文件。文件上传正常,但我不断收到错误。最初的错误是:
Ext.Error:您正在尝试解码无效的JSON字符串:
{"success":true,"msg":"The upload was successful"}
所以在研究之后我看到它说响应内容类型应该是text / html。我更改了我的控制器,使用@RequestMapping注释中的produce标签发送text / html。现在我得到了一个Http Error 406.但是看看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
----------------------------------------------------------
有人有什么想法吗?
答案 0 :(得分:0)
对不起伙计们。一位同事看了这个问题大约20分钟并解决了。他说我在处理上传的控制器方法上没有@ResponseBody注释。我相信我做到了,但我不能证明这一点。哦,它正在发挥作用,这才是最重要的。 : - )