Example of Webwork2 and Springframework Integration (Original) (6) (End)

xiaoxiao2021-03-06  76

6. Comparison of Webwork2 and Spring MVC Framework

Finally, I will list some of the personal opinions of WebWork2 and Spring MVC Framework, and if you are not correct, please correct it.

(1) Basic use

l Spring MVC Framework with other parts of Spring naturally fused, no additional kits and configuration

l Webwork2 and Spring integration requires webwork2-spring.jar to make a connector, and do a quite step configuration, but it is still simple.

(2) Controller

l Spring MVC Framework's controller To implement the Controller interface, the handler is the HandleRequest method, the main task is to construct the MODEL data to return to the view display.

l WebWork2 controller To extend the ActionSupport class (the default implementation of the Action interface), its processing core is an Execute method, because the MODEL data required by the view is existing in the form of an action property, the main task is to set the value of these properties.

(3) Show view content

l Spring MVC Framework only provides taglibs for binding table single field elements, and the view content display function is completed by JSTL.

l Webwork2 needs to use the Taglibs provided by yourself to display the view content, so you can use its characteristics, so you don't need JSTL.

(4) Resource bundle access

l Spring MVC Framework provides a general method: specify (concentrated) to store the properties file of the resource bundle, and can be used well with JSTL

l WebWork2 stores resource bundles using the attribute file corresponding to the Action class name or its parent class name; the resource bundle can be dispersed into the attribute file corresponding to each Action class name, and can also focus on the attribute file corresponding to the parent class, with Access

(5) form interaction

l Spring MVC Framework Using the Command Object (POJO) Package Table Mutual Transfer Data and uses Taglibs to bind the property of the Command object to the table single field element, and set the value of the table single domain element, some complex

l WebWork2 naturally binds the action attribute and form field element, which is relatively simple, but its verification failure error message does not have Spring MVC Framework

(6) Data validity verification

l Spring MVC Framework requires yourself to write a validator, and verify that the rules and logic are mixed together, which is not conducive to reuse

l WebWork2 provides a more flexible verification mechanism: first is to separate verification rules and implementation logic, easy to reuse; followed by WebWork2 and XWork provide a commonly used verifier, no need to write itself; in addition, verification rules are saved with XML files, Modifying the verification rule As long as you modify the XML file, you do not need to modify the code;

(7) Personal view

I think it is better to use WebWork2 to implement the web application layer, although there is some additional configuration, but Webwork2 has some advantages, as the result of the previous form interaction, the rules of data verification and the implementation, and integration OGNL characteristics, Velocity technology, etc. Note: Spring also supports Velocity, there is no in-depth study, you can go to see yourself

转载请注明原文地址:https://www.9cbs.com/read-120771.html

New Post(0)