ssm框架+easyUI模糊搜索。

最近项目赶得紧。自己还感冒了。不在状态,不过幸好做完了。留个纪念。


  toolbar: [{
 text: ' 文章名:<input type="text" id="title"/>' 
     		   }, {
                iconCls: 'icon-search',
                text: '查询',
                handler: function () {
                  findMess(); 
                }
            }]
上文是jsp页面需要写的代码

var findMess = function(){
		  $("#MessPubList").datagrid('load', {
            "title" : $("#title").val()
        });
				
	}

上面为点击查询时候所调用的方法。

@RequestMapping("findByTitle")
	@ResponseBody
	public String  findByTilte(@RequestParam(value = "title",required = false)String title){
		List<MessPublish>	List = MessPubservice.findByTitle(title);
		String json = "";
		int total = MessPubservice.total();
		Map map = new HashMap<String, Object>();
		map.put("total", total);
		map.put("rows", List);
		json = JSONObject.fromObject(map).toString();
		return json;
	
	}



控制器里写入这个方法easyUI控件比较智能会根据你输出的值判断

	List<MessPublish> findByTitle(String title);  业务层方法
@Override
	public List<MessPublish> findByTitle(String title) {
		List<MessPublish> find =  mapper.findByTitle(title);      业务层实现方法比较简单
		return find;             
	}
List<MessPublish> findByTitle(String title);  mapper 里面写的方法
	<select id="findByTitle" parameterType="String" resultType="MessPublish">
		select ID,Title,MessContent,CreateTime,TypeID,CorpID,UserName,UserID,ModifyTime,CheckState,CheckTime,CheckID,CheckRemark,Mess_Fujian from Mes_publish
			<where>
			<if test=" _parameter!=null and  _parameter!='' ">   
				and Title like  '%'+#{_parameter}+'%' 
			</if>
			</where>
	</select>
上面为mapper里面的select 语句片段好了,记录到这。最后来前台展示

好了记录完活。最后希望大家不要感冒,最近头疼的厉害,写代码完全没有思路。


  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值