0

我有一个控制器,它有一个接口作为代理

@Controller
public class MyController implements IMyController{

    public FormBean getCommand(){
        return new FormBean();
    }

    public String onLoad(HttpServletRequest req,HttpServletResponse res){
    }
}

界面如下:

public interface IMyController {

    @ModelAttribute("formBean")
    FormBean getCommand();

    @RequestMapping("/onload.do")
    String onLoad(HttpServletRequest req,HttpServletResponse res);
}

问题是,不会随时调用 getCommand() 方法。我也尝试过将模型属性注释移动到实现类,但无济于事。

我哪里错了?

4

1 回答 1

0

Try this

public String onLoad(@ModelAttribute("formBean") FormBean form, HttpServletRequest req,HttpServletResponse res) {       
   return "pageName";
}
于 2013-05-24T06:56:14.103 回答