当前位置:网站首页>Function of contenttype

Function of contenttype

2022-07-06 05:58:00 The corner of fufu

One 、ContentType The role of

ContentType Decide how the browser handles the response body

 Insert picture description here

Two 、 Different types of performance effects

Achieve different performance effects for the following programs

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    
		String output = "<h1><a href='http://www.baidu.com'><span> Baidu </span></a></h1>";
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().println(output);

1、text/html:html file

text/html Here is the reference
html file  Insert picture description here
Debug page  Insert picture description here

2、text/plain: Pure text

text/plain Insert picture description here
Pure text
 Insert picture description here
Debug page
 Insert picture description here

3、text/xml:XML file

text/xml
 Insert picture description here
XML file
 Insert picture description here
Debug page
 Insert picture description here

4、application/x-msdownload: Resources to download

application/x-msdownload
 Insert picture description here
Download resources
 Insert picture description here
Debug page
 Insert picture description here

原网站

版权声明
本文为[The corner of fufu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060547558213.html