tailieunhanh - Expert Spring MVC and Web Flow phần 6

Xác nhận là thực hiện trong phong cách trọn vẹn như người dùng di chuyển theo hướng dẫn, xác nhận bộ phận duy nhất của đậu lệnh trên mỗi bước. Tại bước cuối cùng trong wizard, tất cả các kiểm chứng thực được chạy lại theo thứ tự, | CHAPTER 6 THE CONTROLLER MENAGERIE 193 Validation is done in piecemeal style as the user moves through the wizard validating only parts of the command bean on each step. At the last step in the wizard all validations are run again in order effectively validating the complete command bean. This controller should not be used for arbitrary work flows. Instead you should use Spring Web Flow which is capable of handling complex state changes and page flows. ThrowawayController There are at least two schools of thought on how to model a request response-type web framework. The first says that the request is something that should be passed around to stateless handlers which is exactly how servlets and Controllers work. The second school of thought says that the request should be modeled with the Command pattern and directly executed. This matches how WebWork http webwork has modeled its request handling for instance. If this is your cup of tea Spring MVC provides an that implements the Command pattern for request handling. Up to now you ve seen Controllers as stateless singletons in the system working directly with the HttpServletRequest and HttpServletResponse objects in order to process requests. The ThrowawayController provides the alternative to this model because it encapsulates both the state of the request as well as the behavior. The ThrowawayController is also a prototype bean a new instance is created for each request. For these reasons ThrowawayControllers are an entirely different breed of request handler so much so that they don t even implement the Controller interface. rip Controllers such as SimpleFormController do not have to be singletons. You may configure any controller type as a prototype if you wish but ThrowawayController must be a prototype because its design is not thread safe. ThrowawayControllers are meant to act as the command bean and the request handler. .

TỪ KHÓA LIÊN QUAN