2013-02-08 84 views
0

如果我發送一個包含表單的UTF-8編碼的HTML頁面,那麼瀏覽器沒有在POST請求標題參數中指定編碼是否正確?POST請求標題中缺少編碼

我用當前版本的Firefox 18和Internet Explorer 9測試了它(見下文)。

根據對Why does POST not honor charset, but an AJAX request does? tomcat 6的回答,設置HTML頁面編碼'將設置響應編碼爲UTF-8並將響應標頭設置爲UTF-8'。

在我的測試中,響應頭沒有指定表單值以UTF-8編碼。

這是否符合規定?

Request: POST /demo/form.html HTTP/1.1 
Accept: text/html, application/xhtml+xml, */* 
Referer: http://127.0.0.1:8080/demo/form.html 
Accept-Language: de 
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0) 
Content-Type: application/x-www-form-urlencoded 
Accept-Encoding: gzip, deflate 
Host: 127.0.0.1:8080 
Content-Length: 29 
Connection: Keep-Alive 
Cache-Control: no-cache 
+0

可能會幫助你http://stackoverflow.com/questions/2418944/how-to-force-browser-to-set-charset-in-content-type-http-header – Venu 2013-02-08 17:07:59

回答

1

中的應用/ X WWW的窗體-urlencoded媒體類型不具有字符集參數,所以瀏覽器行爲是正確的。