我正在尝试使用 extjs 4 和 Spring 3.1 上传文件。文件正确上传,但我不断收到响应错误。最初的错误是:
Ext.Error:您正在尝试解码无效的 JSON 字符串:
{"success":true,"msg":"上传成功"}
因此,经过研究,我看到它说响应内容类型应该是 text/html。我将控制器更改为使用 @RequestMapping 注释中的生产标记来发送文本/html。现在我得到一个 Http 错误 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
----------------------------------------------------------
有人有什么想法吗?