日期:2014-05-20 浏览次数:21126 次
<a href="javascript:doSubmit('${pageContext.request.contextPath}/beneficiary.do?menu=modifyPage&id=<%=id%>')"><img src="file:///D|/My Documents/未命名站点 1/print.jpg"></a>
public ActionForward modifyPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException { String code=(String)request.getParameter("code"); System.out.println(code); BeneficiaryForm f = (BeneficiaryForm) form; f.setId(code); List beneficiaryList = (List) beneficiaryDao.queryByOne(f.getId()); request.setAttribute("beneficiaryList", beneficiaryList); return mapping.findForward(this.MODIFY_PAGE);//前往修改表单页 }
List beneficiaryList = (List) beneficiaryDao.queryByOne(f.getId());
public List<?> queryByOne(String code) { List<?> list = this.getHibernateTemplate().find("from Beneficiary where code="+code); return list; }
在显示数据页面按下<a href="javascript:doSubmit('${pageContext.request.contextPath}/accreditor.do?menu=modifyDo&id=<%=id%>')"><img src="file:///D|/My Documents/未命名站点 1/print.jpg"></a>这个超链接后
public ActionForward modifyDo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException { String code=(String)request.getParameter("code"); System.out.println(code); BeneficiaryForm f = (BeneficiaryForm) form; f.setId(code); Beneficiary beneficiary = new Beneficiary(); MyBeanUtils.copyBean2Bean(beneficiary, f); beneficiaryDao.updateById(f.getId(), beneficiary); return indexPage_show(mapping, form, request, response);//修改后,前往列表页,显示刚修改过的数据行 }
public void updateById(String id, Beneficiary roomExample) throws IllegalAccessException, InvocationTargetException{ Beneficiary oldRoom = queryById(id); MyBeanUtils.copyBean2Bean(oldRoom, roomExample); this.getHibernateTemplate().saveOrUpdate(oldRoom); }