在Spring 3中使用OnSubmission

在Spring 3中使用OnSubmission,spring,spring-mvc,spring-3,Spring,Spring Mvc,Spring 3,我在控制器中使用spring 3 RequestMapping,定义如下: @RequestMapping(value = "/myServlet" , method = RequestMethod.GET) public @ResponseBody String performAction() { return "success"; } 我正在尝试实现一个使用Spring 2方法参数的方法,SimpleFormController正在扩展,OnSubm

我在控制器中使用spring 3 RequestMapping,定义如下:

@RequestMapping(value = "/myServlet" , method = RequestMethod.GET)
      public @ResponseBody String performAction() {
        return "success";
      }
我正在尝试实现一个使用Spring 2方法参数的方法,SimpleFormController正在扩展,OnSubmistation正在重写,并且正在调用一个使用OnSubmistation参数的方法:

    protected void onSubmitAction(ActionRequest request,
                                  ActionResponse response,
                                  Object command,
                                  BindException errors)
{
methodCall(request,response,command,errors);
}

是否可以使用spring 3 annotation@RequestMapping访问这些参数(请求、响应、命令、错误),或者我是否需要以不同的方式实现我的控制器?

spring MVC在将请求数据绑定到控制器方法参数方面非常智能

下面是我自己的一些代码中的一个示例,通过示例可以回答您的问题:

@RequestMapping(value = "/my-account/email", method = RequestMethod.PUT)
public ModelAndView updateEmail(EditEmailForm editEmailForm, BindingResult result) {
    // ...
}
在这里,SpringMVC智能地将请求参数绑定到我的“命令”对象(editEmailForm),并将/验证结果绑定到结果。可以通过result访问错误,例如result.hasErrors()、result.getErrors()等

很明显,在幕后有很多“魔力”,但是如果你只是在方法签名中“请求”,SpringMVC总是会给你你想要的东西

希望有帮助