无法使用 jqgrid 在jsp上显示json数据。
需要帮助eagarly。
请在下面找到我的JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<!-- <link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.10.2.custom.css" /> -->
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="js/jquery-ui.js" type="text/javascript"></script>
<script src="js/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<title>List Users</title>
<script type="text/javascript">
jQuery().ready(function (){
//alert('Hi');
jQuery("#list1").jqGrid({
url:'dataTablesAction',
datatype: "json",
colNames:['User Id','First Name', 'Last Name', 'Username','Email'],
colModel:[
{name:'name',index:'name', width:75},
{name:'rowId',index:'rowId', width:90},
{name:'task',index:'task', width:100},
{name:'taskTime',index:'taskTime', width:80},
{name:'uId',index:'uId', width:80}
],
rowNum:10,
autowidth: true,
rowList:[10,20,30],
pager: jQuery('#pager1'),
sortname: 'id',
viewrecords: true,
// sortorder: "desc",
caption:"Users"
}).navGrid('#pager1',{edit:false,add:false,del:false});
});
</script>
</head>
<body>
<table id="list1"></table>
<div id="pager1"></div>
</body>
</html>
这是我的行动:
公共类TaskViewAction实现Action {
private List<DailyTasks> detailsList;
public List<DailyTasks> getDetailsList() {
return detailsList;
}
public void setDetailsList(List<DailyTasks> detailsList) {
this.detailsList = detailsList;
}
@Override
public String execute() throws Exception {
detailsList = ExcelServices.readFromExcel("U:\\test.xlsx");
return Action.SUCCESS;
}
}
struts.xml中
<struts>
<package name="default" extends="json-default">
<action name="dataTablesAction" class="com.action.TaskViewAction">
<result type="json">
<param name="excludeNullProperties">true</param>
<param name="noCache">true</param>
</result>
<result type="json" />
</action>
</package>
</struts>
我在浏览器的控制台中接收数据。我已经从chrome中的开发人员工具中检查了这个。
也没有错误或例外。
我是否必须在JSP中进行更改?