簡體   English   中英

HTTP:要設置字符集要添加什么頭?

[英]HTTP: What header to add in order to set the charset?

我在RESTFul Web服務上獲得了以下Java代碼:

 Response response = Response.ok().
             entity(method(paramether)).
             header("Access-Control-Allow-Origin", "*").build();

我想添加一些標頭,使我可以通過HTTP本身將字符集設置為UTF-8(因為嘗試僅在文檔中設置時會遇到一些問題)。 提前致謝。

Content-Type ,例如:

Content-Type: text/html;charset=UTF-8

Content-Type標頭可用於指定您返回的內容的類型以及其字符集。

舉個例子:

Content-Type: text/html; charset=utf-8

摘自Wikipedia上HTTP標頭的文章https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM