接下来使用easyui实现数据的增删查改
利用form和dialog进行布局,然后利用datagrid(‘getSelected’)进行数据回显以及传递数据操作所需的值前后端分离
1.编写UserDao方法
package com.ningjie.dao;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ningjie.util.JsonBaseDao;
import com.ningjieutil.JsonUtils;
import com.ningjie.util.PageBean;
import com.ningjieutil.StringUtils
public class UserDao extends JsonBaseDao {
/**
* 查询方法
* @param paMap
* @return
* @throws Exception
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public List<Map<String, Object>> look( Map<String,String[]> paMap,PageBean pageBean) throws Exception, SecurityException, IllegalArgumentException, IllegalAccessException, SQLException {
String sql =" select * from t_easyui_user_version2 where true ";
//获取你要查询的值str
String uname =JsonUtils.getParamVal(paMap, "uname");
//确定要传的str值,在sql的基础上加模糊查询语句
if(StringUtils.isNotBlank(uname)) {
sql =sql +"and uname like '%" +uname.trim() +"%'";
}
//返回一个执行查询的方法
return super.executeQuery(sql, pageBean);
}
/**
* 修改方法
* @param paMap
* @return
* @throws Exception
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public int edit(Map<String, String[]> paMap) throws Exception, SecurityException, IllegalArgumentException, IllegalAccessException, SQLException {
String sql ="update t_easyui_user_version2 set uid=?,uname=?,upwd=? where serialno=?";
return super.executeUpdate(sql, new String[] {"uid","uname","upwd","SerialNo"}, paMap);
}
/**
* 增加方法
* @param paMap
* @return
* @throws Exception
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public int add(Map<String, String[]> paMap) throws Exception, SecurityException, IllegalArgumentException, IllegalAccessException, SQLException {
String sql ="insert into t_easyui_user_version2 (uid,uname,upwd) values (?,?,?)";
return super.executeUpdate(sql, new String[] {"uid","uname","upwd"} , paMap);
}
/**
* 删除方法
* @param paMap
* @return
* @throws Exception
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public int del(Map<Str