当前位置: 代码迷 >> J2EE >> 列名无效.何错之有解决办法
  详细解决方案

列名无效.何错之有解决办法

热度:99   发布时间:2016-04-22 02:26:27.0
列名无效...何错之有
1.按下这超链接
Java code
<a href="javascript:doSubmit('${pageContext.request.contextPath}/beneficiary.do?menu=modifyPage&id=<%=id%>')"><img src="file:///D|/My Documents/未命名站点 1/print.jpg"></a>

2.跳转到
Java code
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);//前往修改表单页    }    

3.其中进入了这个到
Java code
List beneficiaryList = (List) beneficiaryDao.queryByOne(f.getId());
Java code
public List<?> queryByOne(String code) {                List<?> list = this.getHibernateTemplate().find("from Beneficiary where code="+code);        return list;        }

在页面显示这列所有数据
Java code
在显示数据页面按下<a href="javascript:doSubmit('${pageContext.request.contextPath}/accreditor.do?menu=modifyDo&id=<%=id%>')"><img src="file:///D|/My Documents/未命名站点 1/print.jpg"></a>这个超链接后

跳转到
Java code
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);//修改后,前往列表页,显示刚修改过的数据行    }
其中这个跳转中进入了一个dao
Java code
public void updateById(String id, Beneficiary roomExample) throws IllegalAccessException, InvocationTargetException{        Beneficiary oldRoom = queryById(id);        MyBeanUtils.copyBean2Bean(oldRoom, roomExample);        this.getHibernateTemplate().saveOrUpdate(oldRoom);    }





------解决方案--------------------
Beneficiary 确认 你这个bean 的类型 名称 与数据库的能对应上?
------解决方案--------------------
从你的错误信息看.就是那个dao有问题.检查一下!
------解决方案--------------------
code 是不是数据库中是不是 varchar?

把下面语句
List<?> list = this.getHibernateTemplate().find("from Beneficiary where code="+code);
改成
List<?> list = this.getHibernateTemplate().find("from Beneficiary where code=‘"+code+“’”);
试试看!

------解决方案--------------------
  相关解决方案