我正在使用Angular JS和Material设计创建一个带有前端的示例Web应用程序。我是一个前端人,并且不太了解支持。我想创建一个JSP页面,它将创建json并作为我的应用程序的服务。我编写了如下代码
<%@page contentType="application/json; charset=UTF-8"%>
<%@page import="org.json.simple.JSONObject"%>
<%@page import="org.json.simple.JSONArray"%>
<%
JSONObject userAppJsonObj = new JSONObject();
userAppJsonObj.put("icon","fa fa-2x fa-home");
userAppJsonObj.put("title","Home");
userAppJsonObj.put("authorized",true);
out.print(userAppJsonObj);
out.flush();
%>
以上工作正常。当我想要输出josn如下时,我在迭代中发现了一些困难
[
{ icon: "fa fa-2x fa-home", title: "Home", authorized: true },
{ icon: "fa fa-2x fa-line-chart", title: "About", authorized: true },
{ icon: "fa fa-2x fa-code", title: "Service", authorized: true },
{ icon: "fa fa-2x fa-bar-chart", title: "Blog", authorized: true },
{ icon: "fa fa-2x fa-flask", title: "Contact", authorized: true },
{ icon: "fa fa-2x fa-pie-chart", title: "Studio", authorized: true },
{ icon: "fa fa-2x fa-object-group", title: "Map", authorized: true },
{ icon: "fa fa-2x fa-database", title: "Offers", authorized: true },
]
提前致谢。