application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。
application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。
当前回答
内JSP JSP,您可以在页面指令中使用此指令:
<%@ page language="java" contentType="application/json; charset=UTF-8"
pageEncoding="UTF-8"%>
正确无误米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米米JSON 是application/json
JSP将使用它向客户发送回复。
其他回答
如果您在客户端环境中, 调查交叉浏览器支持是强制的, 对于一个支持良好的网络应用程序来说 。
正确的 HTTP 内容类型application/json
,正如其他人也已经强调过, 但有些客户对它处理得不好, 这就是为什么jQuery建议默认text/html
.
PHP 开发商使用此功能 :
<?php
header("Content-type: application/json");
// Do something here...
?>
“application/json
”是正确的JSON内容类型。
def ajaxFindSystems = {
def result = Systems.list()
render(contentType:'application/json') {
results {
result.each{sys->
system(id:sys.id, name:sys.name)
}
}
resultset (rows:result.size())
}
}
如果从JSON的REST API获得数据,必须使用内容类型:
为补充先前的答复,JSON 链接数据的MIME类型(JSON-LD)以 W3C 计算是:
application/ld+json
类型名称 :应用
子类型名称 :Ld+json 键盘
此外,来自同一来源的:
文件扩展名:
.jsonld