任何人都可以给我一个例子,说明如何从没有任何外部库的jsp返回以下json(除了Oracle Java标准的那些)?
[
{"label":"item 1", "value":"item 1", "id": 1},
{"label":"item 2", "value":"item 2", "id": 2},
{"label":"item 3", "value":"item 1", "id": 3}
];
Run Code Online (Sandbox Code Playgroud)
我试过了
<%-- Set the content type header with the JSP directive --%>
<%@ page contentType="application/json" %>
<%-- Set the content disposition header --%>
<%
// Returns all employees (active and terminated) as json.
response.setContentType("application/json");
response.setHeader("Content-Disposition", "inline");
%>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="oracle.apps.fnd.common.WebAppsContext"%>
<%@ page import="oracle.apps.fnd.common.WebRequestUtil"%> …Run Code Online (Sandbox Code Playgroud)