2012-09-23 24 views
0

我有一个JS应用程序,它设置一个iframe URL来定位我的appengine服务。间歇地返回的页面的内容类型为'application/json'而不是'text/html'。重复调用总是用作“text/html”。Appengine为什么有时会更改内容类型?

这就是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 
+0

上面的网址不是来自Appengine,那么这与Appengine有什么关系? –

+0

Appengine的** **是**!如果有帮助,我很乐意将其指定为http://clever-note.appspot.com。 – pinoyyid

+0

我得到“错误:服务器错误”,如果我尝试该网址? –

回答

1

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

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

     response.setContentType("text/html; charset=UTF-8");  
     //...   
} 
+0

T hx,但我已经这样做了,并且还在servlet(well JSP)中设置了http content-type头。 Appengine的前端似乎忽略了它。 – pinoyyid

1

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

<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
+0

Thx安德烈的建议,我会尝试它并监视结果 – pinoyyid

+0

这是一个可怕的想法,并且是一个可以正确设置内容类型的不好的替代品 –

相关问题