ajax对action json串操作(可操作大量数据,常用于页面数据加载,如分页)
1:js
<scripttype="text/javascript">
$(document).ready(function(){
fn_Jump(1);
});
functionfn_Jump(gotoPage)
{
jQuery.ajaxSetup({cache:false});
varfirst="2012-1-1";
varlast="2013-12-31";
$.getJSON("testJsonAction!openByEmpId2.action",{first:first,last:last,currPage:gotoPage},function(json){
if(json.msg!="none"){
vardataString="";
dataString+="<TR>";
vardata=json.annList;
for(indexindata){
varobj=data[index];
dataString+="<TD>"+obj.fsContent+"</TD>";
}
dataString+="</TR>";
$("#dataList").append(dataString);
}
});
}
</script>
2:struts.xml文件中的配置
<!DOCTYPEstrutsPUBLIC
"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<packagename="ann2"extends="json-default">
<actionname="testJsonAction"class="com.asia.home.cn.web.oa.TestJsonAction">
<resulttype="json"/>
</action>
</package>
</struts>
3:action
privateIRepAnnounceServiceannounceService;
privateList<RepAnnounce>annList;
privateStringmsg;
//按发布者查询公告
publicStringopenByEmpId2(){
try{
StringreadType=request.getParameter("readType");
StringfsEmpid="93b7f205-0134-1000-e000-35630a0000fa";
Stringauthor=UrlUtils.decode(request.getParameter("author"),
"utf-8");
Stringlast=request.getParameter("last");
Stringfirst=request.getParameter("first");
this.annList=announceService.findAnn(fsEmpId,newPage(),readType,
author,last,first);
}catch(Exceptione){
logger.info(e);
}
returnSUCCESS;
}
publicvoidsetAnnounceService(IRepAnnounceServiceannounceService){
this.announceService=announceService;
}
相关推荐
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo