1.前端jsp页面

<div class="tab_tip">
请输入[身份证号或姓名]
<input type="text" class="tab_getText" id="tab1_getText"> <input type="button" class="tab_selectButton" id="tab1_selectButton" value="查询">
</div>
<!-- 省略代码 -->
<table class="table" id="table1" cellspacing="0" cellpadding="0">
<tr>
<th>个人编号</th>
<th>身份证号</th>
<th>姓名</th>
<th>性别</th>
<th>民族</th>
<th>出生年月</th>
<th>参加工作时间</th>
<th>缴费基数</th>
<th>单位编号</th>
<th>单位简称</th>
<th>人员状态</th>
</tr>
</table>

2. JavaScript处理代码

$(function(){
$("#tab1_selectButton").unbind('click').click(function(){
var tab1_getText = $.trim(document.getElementById("tab1_getText").value);
if(tab1_getText != ""){
$.ajax({
type:"POST",
url:"getStaffAllSelect/"+tab1_getText+"/0",
async:false,
dataType:"json",
success:function(data){
$(".staffallinfotr").remove();
for(i=0;i<data.length;i++){
$("#table1").append('<tr class="staffallinfotr"><td>'+data[i].sid+'</td><td>'+data[i].sino+'</td><td>'+data[i].sname+'</td><td>'+data[i].ssex+'</td><td>'+data[i].snation+'</td><td>'+data[i].sbirth+'</td><td>'+data[i].sdaj+'</td><td>'+data[i].pbase+'</td><td>'+data[i].cid+'</td><td>'+data[i].csn+'</td><td>'+data[i].sstate+'</td></tr>');
}
},
error:function(){
alert("error");
},
complete : function(XMLHttpRequest,status){
   if(status=='timeout'){
      ajaxTimeoutTest.abort();
     alert("超时");
   }
} });
}else{
alert("请输入个人编号或姓名!");
}
});
});

3.Controller类中方法(注:StaffAllSelectDTO:和前端jsp页面中的table字段相同,因为代码过长,就不再贴出)

@RequestMapping("/getStaffAllSelect/{sname}/{start}")
public @ResponseBody List<StaffAllSelectDTO> getStaffAllSelect(@PathVariable String sname, @PathVariable int start){
List<StaffAllSelectDTO> staffAllSelectDTOList = staffServices.getStaffAllSelectByName(sname, start, 10);
for(int i=0;i<staffAllSelectDTOList.size();i++){
System.out.println(staffAllSelectDTOList.get(i));
}
return staffAllSelectDTOList;
}

4. Services类中方法

@Override
public List<StaffAllSelectDTO> getStaffAllSelectByName(String sname, int start, int limit) {
// TODO Auto-generated method stub
List<Staff> staffList = staffDAO.getStaffsByName(sname, start, limit);
List<StaffAllSelectDTO> staffAllSelectDTOList = staffFactory.staffAndStaffPaymentToStaffAllSelectDTO(staffList);
return staffAllSelectDTOList;
}

5. DAO类中方法

@Override
public List<Staff> getStaffsByName(String sname, int start, int limit) {
// TODO Auto-generated method stub
Map<String, Object> map = new HashMap<String, Object>();
map.put("sname", sname);
map.put("start", start);
map.put("limit", limit);
return getSqlSession().selectList("com.staff.entity.StaffMapper.getStaffsByName", map);
}

6. DTO: StaffAllSelectDTO:和前端jsp页面中的table字段相同,因为代码过长,就不再贴出)

7. Mybatis

<select id="getStaffsByName" parameterType="Map" resultMap="StaffResult">
select s.sid,s.sino,s.sname,s.ssex,s.snation,s.sbirth,s.sdaj,s.sstate,s.spbase,s.cid,c.csn,c.cname from staffinfo s, companyinfo c where s.cid = c.cid
<if test="sname != null and !&quot;&quot;.equals(sname)">and s.sname like CONCAT('%',#{sname,jdbcType=VARCHAR},'%')</if>
<if test="start!=null and limit!=null">
limit #{start},#{limit}
</if>
</select>

最新文章

  1. Trie tree实践
  2. Azure ARM (4) 开始创建ARM Resource Group并创建存储账户
  3. C# SMTP邮件发送 分类: C# 2014-07-13 19:10 334人阅读 评论(1) 收藏
  4. iOS 杂笔-20(UIView和CALayer的区别与联系)
  5. 20145103 《Java程序设计》第2周学习总结
  6. 关闭WordPress自动加载的Open Sans字体-WP访问过慢原因
  7. UI布局
  8. 关于CSS中的PX值(像素)
  9. MySQL UNION 与 UNION ALL 语法与用法
  10. Extjs 4.1 struts2.3 返回json 初试
  11. 解决asp.net MVC中 当前上下文中不存在名称“model” 的问题
  12. EXCEL记录
  13. es过滤集提升权重
  14. [Swift]LeetCode64. 最小路径和 | Minimum Path Sum
  15. UGUI中UI与模型混合显示
  16. Android5.0 ListView特效的简单实现
  17. 每日英语:Does China Face a Reading Crisis?
  18. mysql show global variables字符超1024会被截断
  19. 【cs229-Lecture2】Gradient Descent 最小二乘回归问题解析表达式推导过程及实现源码(无需迭代)
  20. 线程8--GCD常见用法

热门文章

  1. linux or msys2设置网络代理
  2. 118. Pascal&#39;s Triangle@python
  3. mysql 审核引擎 goInception 的基本使用
  4. python面向对象(C3算法)(六)
  5. centos中python2替换为python3,并解决yum出错
  6. java null 空指针
  7. jmx_exportter+prometheus+grafana监控hadoop
  8. 【18】什么是FOUC?如何避免
  9. luogu3759 [TJOI2017]不勤劳的图书管理员
  10. 【编程工具】Sublime Text3快捷键配置