81,090
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
$(document).ready(function() {
initCommonJS();
$("#gridTable").datagrid({
url:'fetchUserList.action?t=' + new Date(),
width:750,
sortName: 'name',
sortOrder: 'desc',
pagination:true,
rownumbers:true,
pageList:[15,30,50,100],
columns:[[
{field:'id',title:'id',width:30,hidden:true},
{field:'ck',checkbox:true,width:30},
{field:'name',title:'姓名',width:80,sortable:true},
{field:'old',title:'年龄',width:60,align:'center',sortable:true}
]],
toolbar:[{
id:'btnadd',
text:'增加',
iconCls:'icon-add',
handler:function(){
checkOpenUrl("#gridTable","useredit.html",550,420,"增加","用户");
}
},{
id:'btnremove',
text:'删除',
iconCls:'icon-remove',
handler:function(){
checkSelectSomeDoFunc("#gridTable","删除","用户",
function(ids){
$.post("deleteUsers.action?selectedIds="+ids+"&t="+new Date(),{},function(result){
if (result=="success"){
$("#gridTable").datagrid("reload");
}else{
alert(result);
}
});
},
true
);
}
},{
id:'btnedit',
text:'修改',
iconCls:'icon-edit',
handler:function(){
checkSelectOneOpenUrl("#gridTable","useredit.html",550,420,"修改","用户");
}
}]
});
});
</script>
$("#gridTable").datagrid({
url:'fetchUserList.action?t='
这个action里面是这样写的,
public String fetchUserList(){
this.rowsBook = this.bookService.findAll();
this.total_b = this.rowsBook.size();
return SUCCESS;
}
findall方法是这么写的
public List<Book> findAll() {
return this.getHibernateTemplate().find("from Book");
}
返回的是一个list集合,我想问的是在struts2的xml中怎么配置,然后在前台怎么取得查询出来的数据。