2 yjwzsrzj YJWZSRZJ 于 2017.09.07 10:37 提问

Easuyi 修改了数据,刷新不了页面,数据是一直保持不表,当数据库已经改变,只有从刷新

//删除
function deleteUser(){
var row = $('#dg').datagrid('getSelected')
location.href="delete.action?uid="+row.uid

}

//修改
function updateUser(){
var row = $('#dg').datagrid('getSelected');
location.href="update.action?uid="+row.uid+"&uname="+row.uname+"&ucard="+row.ucard+"&ugender="+row.ugender+"&uphone="+row.uphone+"&ucount="+row.ucount

var row = $('#dg').datagrid('reload');
}


// 删除
@Action(value = "delete", results = { @Result(name = "succes", location = "/WEB-INF/jsp/user.jsp") })
public String delete() {
    HttpServletRequest request = ServletActionContext.getRequest();
    Session session = sessionFactory.openSession();
    int uid = Integer.parseInt(request.getParameter("uid"));
    System.out.println(uid);
    UserEntity userEntity = session.load(UserEntity.class, uid);
    session.delete(userEntity);

    session.beginTransaction().commit();

    session.close();
    return "succes";
}

// 修改
@Action(value = "update",results ={@Result(name = "succes", location = "/WEB-INF/jsp/user.jsp")})
public String upadte() {
    HttpServletRequest request = ServletActionContext.getRequest();
    Session session = sessionFactory.openSession();
    int uid = Integer.parseInt(request.getParameter("uid"));
    String uname = request.getParameter("uname");
    String ucard = request.getParameter("ucard");
    int ugender = Integer.parseInt(request.getParameter("ugender"));
    String uphone = request.getParameter("uphone");
    int ucount = Integer.parseInt(request.getParameter("ucount"));
    UserEntity userEntity = session.load(UserEntity.class, uid);
    userEntity.setUname(uname);
    userEntity.setUcount(ucount);
    userEntity.setUcard(ucard);
    userEntity.setUphone(uphone);
    userEntity.setUgender(ugender);
    session.update(userEntity);
    session.beginTransaction().commit();

    session.close();

    return "succes";

}

1个回答

zsmj_820_09
zsmj_820_09   2017.09.07 11:37

老哥,easyui有自带的刷新页面的方法,建议详细看下easyui的demo
location.href 这个不要自己写,easyui都是异步的

Csdn user default icon
上传中...
上传图片
插入图片