最近我發現了一個碼頭現象。在eclipse中,我安裝了一個jetty插件來運行web項目。在頁面(jsp)中有一個ajax請求,我發現如果項目是由jetty啓動的,那麼會有500個錯誤,但是如果由tomcat啓動,那沒問題。看下面:爲什麼Jetty無法支持Content Type標題中的重複字符集?
curl -d "category=foo" 'http://localhost:8080/foo/bar' -i
HTTP/1.1 200 OK
Date: Tue, 22 Dec 2015 13:27:35 GMT
Content-Type: text/html;charset=utf-8;charset=UTF-8
Cache-Control: no-cache
Expires: 0
Pragma: no-cache
Content-Length: 20086
Server: Jetty(8.1.14.v20131031)
curl: (18) transfer closed with 20086 bytes remaining to read
請警告上面的內容類型頭,charset是重複的,所以導致此錯誤。 然後我改變了設置內容類型的代碼,再次請求,現在沒關係。
HTTP/1.1 200 OK
Date: Thu, 24 Dec 2015 03:00:33 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Expires: 0
Pragma: no-cache
Content-Length: 83
Server: Jetty(8.1.14.v20131031)
{"altMessage":null,"desc":null,"map":null,"message":"[]","prop":null,"rsCode":"ok"}
所以我想知道爲什麼Jetty不能支持內容類型標題中的重複字符集?