我正在尝试使用Struts2和jQuery网格显示输出。我正在获得正确的JSON输出。但我无法使用Strut2 jQuery网格将结果页面显示到JSP页面中。我的JSON输出如下:
{"gridModel":[[81,1],[82,1],[83,1],[84,1],[85,1],[86,1],[87,1],[88,1],[89,1],[90,1]],"page":0,"records":10,"rows":0,"searchField":null,"searchOper":null,"searchString":null,"sidx":null,"sord":null,"total":2147483647}
你能告诉我为什么我无法显示网格表。我的完整代码如下:
<action name="product" class="com.example.ProductAction">
<result>/pages/ .jsp </result>
</action>
<action name="productJson" class="com.example.JSONProduct" method="execute">
<result type="json" />
</action>
public class JSONProduct extends ActionSupport {
List<Product> gridModel;
private Integer rows = 0;
private Integer page = 0;
private String sord;
private String sidx;
private String searchField;
private String searchString;
private String searchOper;
private Integer total = 0;
private Integer records = 0;
// getter and setter
public String execute(){
int to = (rows * page);
int from = to - rows;
ProductDAO dao = new ProductDAO();
records = dao.getAllProduct().size();
gridModel = dao.getAllProduct();
total =(int) Math.ceil((double)records / (double)rows);
System.out.println(gridModel);
return SUCCESS;
}
public String getJSON(){
return execute();
}
}
public class ProductAction extends ActionSupport {
public String execute(){
return SUCCESS;
}
}
<s:url var="remoteurl" action="productJson" />
<sj:head jqueryui="true" jquerytheme="redmond" />
<sjg:grid id="gridtable" caption="Data" dataType="json"
href="%{remoteurl}" pager="true" gridModel="gridModel"
rowList="10,15,20" rowNum="15" rownumbers="true">
<sjg:gridColumn name="id" index="id" title="Product ID" />
<sjg:gridColumn name="quantity" index="quantity" title="Product quantity" />
</sjg:grid>
答案 0 :(得分:0)
sj:head
标记在HTML head
标记正文中使用。尝试将标记移动到head标记。
<head>
<sj:head jqueryui="true" jquerytheme="redmond" />
<title></title>
</head>