那不是自动初始化功能,只是上一次输入的结果没有被清空,你只需在formbean中实现一个用来清空所有属性的reset方法,然后每次用完后调用它就可以了。

解决方案 »

  1.   

    to  hxzg001(大家踊跃结贴啊):
    我按照你的方法试了一下,好像还是不行,下面是我的实现,你看看有没有什么问题:我在 formBean中加入如下代码:public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
       String bookingContent="";
       String depts="";
       String end_minute="";
       String end_hour="";
       String end_date="";
       String end_month="";
       ........
      }在action中这样:public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) {
          .......
          form.reset(actionMapping,request);
          return actionMapping.findForward("success");
    }
      

  2.   

    这样写是不对的
    首先reset可以不需要参数,而且你在reset中并不是清空了formbean中的属性,而是定义了一堆局部变量,应该是下面的形式
    public void reset() {
       bookingContent="";
       depts="";
       end_minute="";
       end_hour="";
       end_date="";
       end_month="";
       ........
      }
      

  3.   

    楼上正解,bookingContent等等对应formbean中的各个属性
      

  4.   

    reset方法中的参数ActionMapping mapping, HttpServletRequest request还是要的,否则这个reset方法变成你的formbean中的公用方法,系统不会自动调用了。只要把你定义的变量换成你的类属性就可以了,这可是个低级错误哦。