服务器返回错误error on line 1 at column 1: Document is empty

This page contains the following errors:
error on line 1 at column 1: Document is empty

Below is a rendering of the page up to the first error.

查看response , 已经返回数据, 只是页面报错。

原因无法正常处理返回内容的格式。

解决方法:更改ContentType

之前:

response.setContentType("text/xml");


更改为text/plain后不再报错。

response.setContentType("text/plain;");


资料:

text/html与text/plain有什么区别?

Content-Type:用于定义用户的浏览器或相关设备如何显示将要加载的数据,或者如何处理将要加载的数据

  MIME:MIME类型就是设定某种扩展名的文件用一种应用程序来打开的方式类型,当该扩展名文件被访问的时候,浏览器会自动使用指定应用程序来打开。多用于指定一些客户端自定义的文件名,以及一些媒体文件打开方式。


text/html的意思是将文件的content-type设置为text/html的形式,浏览器在获取到这种文件时会自动调用html的解析器对文件进行相应的处理。

text/plain的意思是将文件设置为纯文本的形式,浏览器在获取到这种文件时并不会对其进行处理。


posted @ 2018-05-28 20:06  thewindkee  阅读(6103)  评论(0编辑  收藏  举报