2009-08-17 7 views

答えて

0

MultiActionControlller APIによる

ではなく、宣言コマンド引数に依存するので、お使いのコントローラメソッドでServletRequestDataBinderの直接の使用を考えてみましょう。これにより、バインダーの設定と使用法、バリデーションの呼び出しを含む完全な制御、およびバインド/検証エラーの後続の評価が可能になります。

だから、

public class AddMultiActionController extends MultiActionController { 

    public AddMultiActionController() { 
     // Set up Valang according to your business requirement 
     // You can use xml settings instead 
     setValidators(new Validator [] {new CommandValidator(), new AnotherCommandValidator()}); 
    } 

    public ModelAndView addCommand(HttpServletRequest request, HttpServletResponse response) throws Exception { 
     Command command = new Command(); 

     // createBinder is a MultiActionController method 
     ServletRequestDataBinder binder = createBinder(request, command); 
     // Sets up any custom editor if necessary 
     binder.registerCustomEditor(...); 

     binder.bind(command); 

     return (!(binder.getErrors().hasErrors())) ? new ModelAndView("success") : new ModelAndView("failure"); 
    } 

    // similar approach as shown above 
    public ModelAndView addAnotherCommand(HttpServletRequest request, HttpServletResponse response) throws Exception { 
     AnotherCommand anotherCommand = new AnotherCommand(); 

     ... 
    } 
} 

に関して、

を使用することができます
関連する問題