0

我有一个 JS 应用程序,它设置了一个针对我的 appengine 服务的 iframe URL。返回的页面间歇性地具有“application/json”而不是“text/html”的内容类型。重复调用始终作为“text/html”。

这就是 Chrome 捕获的内容

Request URL:http://www.clevernote.co/app/editpopupG.jsp?u=https://docs.google.com/feeds/download/documents/export/Export?id=1mc_hXOOP-PppCn3GebeGREBRDKLSXp2R1R2ij2_ki_A&exportFormat=html&t=google%20integration&i=1mc_hXOOP-PppCn3GebeGREBRDKLSXp2R1R2ij2_ki_A
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:oauth2-token=; JSESSIONID=DHwIAl
Host:www.clevernote.co
Referer:http://www.clevernote.co/app/main.jsp
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.77 Safari/537.1
Query String Parametersview URL encoded
u:https://docs.google.com/feeds/download/documents/export/Export

Response Headersview source
    Cache-Control:no-cache
    Content-Encoding:gzip
    Content-Length:1544
    Content-Type:application/json; charset=UTF-8
    Date:Sun, 23 Sep 2012 02:49:37 GMT
    Server:Google Frontend
    Vary:Accept-Encoding

如果我重新加载页面,则响应正确为“text/html”

内容 ...

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- CSS -->
<link href="../css/cnw  ... etc
4

2 回答 2

1

尝试在 HTML 文档中设置内容类型:

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
于 2012-09-23T15:23:28.870 回答
1

您可以直接在 servlet 中设置内容类型。

public void doGet(HttpServletRequest request, HttpServletResponse response)...{ 

      response.setContentType("text/html; charset=UTF-8");    
      //...        
}
于 2012-09-23T17:26:53.007 回答