在Server中,可以通过设置Content-Type属性来指定响应的内容类型。以下是一些常见的Content-Type值及其对应的MIME类型:
text/plain:纯文本text/html:HTML文档text/css:CSS样式表application/json:JSON数据application/xml:XML数据application/pdf:PDF文档image/jpeg:JPEG图片image/png:PNG图片audio/mpeg:MP3音频video/mp4:MP4视频在代码中,可以使用response对象的setHeader()方法来设置Content-Type属性。示例代码如下:
response.setHeader("Content-Type", "text/html");response.setHeader("Content-Type", "text/html")response.setHeader("Content-Type", "text/html");header("Content-Type: text/html");response.Headers["Content-Type"] = "text/html";以上代码将设置Content-Type属性为text/html,指示响应内容为HTML文档。根据需要,可以将Content-Type属性设置为其他值来指定不同的内容类型。

