我有一个控制器,它有一个接口作为代理
@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()方法不会随时被调用。我也试过将modelattribute注释移动到实现类但无济于事。
我哪里错了?
答案 0 :(得分:0)
试试这个
public String onLoad(@ModelAttribute("formBean") FormBean form, HttpServletRequest req,HttpServletResponse res) {
return "pageName";
}