急!急求!更新方法 我现在已经得到了专家表的expertid,我想用HibernateTemplate()里面的方法,给expert这个对象更新一下,但不知道怎样做,哪位高手能给小弟指点一下? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那你可以根据这个id去加载对象啊,然后把对象进行修改以后,通过HibernateTemplate去update一下就可以啊! 转载::你可以根据这个id去加载对象啊,然后把对象进行修改以后,通过HibernateTemplate去update一下就可以啊! public void updateExpert(Expert expert) { getHibernateTemplate().update(expert);}public Expert findExpert(Long id) { return (Expert)getHibernateTemplate().get(Expert.class, id);}贴出上面两个方法楼主应该知道怎么做了吧! 谢谢了,那个更新会了。 我还有一个问题,就是用一个超链传一个参数,但是这个超链不是跳到Actiona上,在Actiona里面能用getRequest().getParameter()方法得到那个参数吗? Java codepublic void updateExpert(Expert expert) { getHibernateTemplate().update(expert);}public Expert findExpert(Long id) { return (Expert)getHibernateTemplate().get(Expert.class, id);}引用楼上IceWeepublic ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Expert expert= (Client) request.getSession().getAttribute( "expert"); MyForm myForm = (MyForm) form; myForm.toBean(expert); try { clientService.updateExpert(expert); request.getSession().removeAttribute(Constant.client); addSessionMessage(request, "更新成功",false); } catch (Exception e) { return mapping.findForward("edit"); } return mapping.findForward("list"); } public ActionForward toUpdate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Integer id = Integer.valueOf(request.getParameter("id")); Client client = clientService.findExpert(id); if (client == null) { addError(request, "这个不存在", false); return mapping.findForward("list"); } //添加到session中,以便在update中更新时使用 request.getSession().setAttribute(Constant.client, client); request.setAttribute("updateClient", client); return mapping.findForward("update");/查询结果提交到页面 } 急急急!用Extjs的大侠们,进来说说吧. 如何使用ZK的DOME包 怎么写jstl语句???????? Tomcat下www.acb.com/XXX 形式的二级域名怎么弄呀! 部署servlet错误:就是发布不了。郁闷!!! springMvc定义jdbctemplate出现空指针异常 看看这个需要用到什么帮助?谢谢 连接池问题 求助:能给出一个在jsp里调用ActiveX控件的代码吗? 字符串转数值,泛型类型转换问题 大家一起讨论一下jsp session Cookie 以及javaScript的cookie的应用吧 怎么样寻找合适的JSP虚拟空间,测试的时候出现这个错误
public void updateExpert(Expert expert) {
getHibernateTemplate().update(expert);
}public Expert findExpert(Long id) {
return (Expert)getHibernateTemplate().get(Expert.class, id);
}
贴出上面两个方法楼主应该知道怎么做了吧!
我还有一个问题,就是用一个超链传一个参数,但是这个超链不是跳到Actiona上,在Actiona里面能用getRequest().getParameter()方法得到那个参数吗?
Java code
public void updateExpert(Expert expert) {
getHibernateTemplate().update(expert);
}public Expert findExpert(Long id) {
return (Expert)getHibernateTemplate().get(Expert.class, id);
}
引用楼上IceWee
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Expert expert= (Client) request.getSession().getAttribute(
"expert"); MyForm myForm = (MyForm) form;
myForm.toBean(expert);
try {
clientService.updateExpert(expert);
request.getSession().removeAttribute(Constant.client);
addSessionMessage(request, "更新成功",false);
} catch (Exception e) {
return mapping.findForward("edit");
}
return mapping.findForward("list");
} public ActionForward toUpdate(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Integer id = Integer.valueOf(request.getParameter("id"));
Client client = clientService.findExpert(id);
if (client == null) {
addError(request, "这个不存在", false);
return mapping.findForward("list");
}
//添加到session中,以便在update中更新时使用
request.getSession().setAttribute(Constant.client, client);
request.setAttribute("updateClient", client);
return mapping.findForward("update");/查询结果提交到页面
}