jsonからパラメーターを取得したいので、コードがあります:
@RenderMode(name = "VIEW")
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
resourceRequest.setAttribute("resourceUrl", "http://localhost:8080/");
jsonObject.put("rowsPerPage", 10);
jsonObject.put("page", 1);
jsonObject.put("total", 100);
PrintWriter writer = resourceResponse.getWriter();
writer.write(jsonObject.toString());
}
rowsPerPage、page、total を表示する JavaScript メソッドには何を書くべきか
私はJavaScriptコードを持っています:
$.getJSON('http://localhost:8080/', function(jd) {
alert(jd.rowsPerPage);
});
JSP ページ:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
This is the <portlet:resourceURL var="testURL" id="view.jsp" escapeXml="false" />
<br/><br/>
<div id="myGrid" style="width:600px;height:500px;"></div>
<div id="pager" style="width:600px;height:20px;"></div>
しかし、それは間違っています、なぜですか?