用SSH做的系统,想实现点击后自动加分的功能。
public void updateAccept(int accept,int qid) throws Exception {
Session session = super.getSession();
String hql = "UPDATE Question SET acceptflag=? WHERE qid=?";
Query q = session.createQuery(hql);
q.setInteger(0, accept);
q.setInteger(1, qid);
q.executeUpdate();
releaseSession(session);
}这是数据操作的代码。
struts中action的代码为:
public ActionForward acceptquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 已经采纳答案:accpetflag = 1

AdminquestionForm adminquestionForm = (AdminquestionForm) form;
int qid = Integer.parseInt(request.getParameter("qid")) ;
try {

this.iquestiondao.updateAccept(1,qid) ;

catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
}
return mapping.findForward("updatequestiondo");
}
页面中就是用<html:form>标签来写的,但是奇怪的是报错:java.lang.StackOverflowError。但是数据库里的内容已经被写进去了
在网上查了资料说这个错误是递归引起,但是没发现什么递归啊,很郁闷啊,求高手!

解决方案 »

  1.   

    看看是不是重定向的什么地方错了。
    比如,action处理完返回时又重定向到这个action。这样也是递归(不容易发现)
      

  2.   

    是啊,如果一直在调用这个action,那可不就是java.lang.StackOverflowError + 数据库里的内容已经被写进去了
      

  3.   

    是说“return mapping.findForward("updatequestiondo"); ”
    这个地方的问题吗?
      

  4.   

    dao中的代码是否有问题呢?比如有什么可那产生死循环的地方,递归调用之类的.另外查看数据库中的数据是否正确?
      

  5.   

    跟这个抛出错误 throws Exception 相对应的应该还有句在方法里面。throw new Exception();写方法里面试试
      

  6.   

    那个好像必须要手动抛出一个错误 或者你把方法声明中的throws Exception删掉试试