YJWZSRZJ
一只会飞的白菜
2017-09-07 02:37

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

  • session
  • json
  • 数据库
  • map

//删除
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条回答