processFormSubmission未被调用

时间:2012-08-21 06:21:29

标签: spring

我是春天新手。我正在创建一个简单的登录页面。但是没有调用processFormSubmission()。但是showForm()正在运行。

public class LoginController extends SimpleFormController

{
    private LoginService loginService;

private String loginView;

public LoginService getLoginService() {
    return loginService;
}

public void setLoginService(LoginService loginService) {
    this.loginService = loginService;
}

public String getLoginView() {
    return loginView;
}

public void setLoginView(String loginView) {
    this.loginView = loginView;
}

public LoginController() {
    setBindOnNewForm(true);
}
@Override
protected ModelAndView processFormSubmission(HttpServletRequest request,
        HttpServletResponse response, Object command, BindException errors)
        throws Exception 
{
    TraceUser tr = (TraceUser) command;
    System.out.println(tr);
    //loginService.
    return super.processFormSubmission(request, response, command, errors);
}
@Override
protected ModelAndView showForm(HttpServletRequest request,
        HttpServletResponse response, BindException errors)
        throws Exception {
    ModelAndView mav = new ModelAndView();
    mav.addObject("traceUser", new TraceUser());
    mav.setViewName(getLoginView());
    return mav;
}

}

请帮我解决一下如何进一步处理ModelAndView对象。

1 个答案:

答案 0 :(得分:1)

首先,Controller API的使用被放在一边,支持新的基于注释的控制器(请参阅@RequestMapping注释),类似SimpleFormController的类已被删除现在已经弃用了很长一段时间。

但是,为了回答您的问题,我假设您的表单未声明method="post",默认情况下,SFC将仅考虑POST请求作为表单提交(请参阅isFormSubmission()中的AbstractFormController方法})。是这种情况吗?