要实现一个页面无刷新请求跳转的功能,在jsp点击按钮,而后跳转到后台action进行处理,并将处理结果显示在jsp页面上。html
jsp页面中ajax代码:java
function query(page){ var random=Math.random(); $.ajax({ url:"info.do?sign="+random, type:'post', data:{ 'fundNameCode':encodeURI($("#fundNameCode").val()), 'bulletinType':$("#bulletinType").val(), 'beginDate':$("#beginDate").val(), 'endDate':$("#endDate").val(), 'page':page }, success:function (data){ $('#showMsg').html(data); } }); }
info.do 是跳转请求的action,通过action处理后,将结果data返回到要显示的jsp,通常在jsp页面上写一个div,div的id就是上图代码中的 showMsg。jsp页面经过struts2 标签 展现ajax
jsp页面显示action中查询的listdom
<s:iterator id="msg" value="#request.msglist" status="stu"> <li> ${msg.fundCode} ${msg.FundName} <s:date name="bulletinDate" format="yyyy-MM-dd"/> </li> </s:iterator>