Comparison of Struts and WebWork2 [Quote]

xiaoxiao2021-03-06  94

?

Compare the Struts Webwork2 Action class In Struts, each Action Class needs to expand org.apache.struts.Action.Action; this will attract some problems in Java program, is about a variety of inheritance, WebWork only requires Implement COM .opensymphony.xwork.action interface, you can also implement more features, such as: Validate, Localware (International), etc., of course, WebWork2 also provides a class ActionSupport integration. Developer can achieve different functions as needed. The thread model Struts Action must be a Thread-Safe method, which only allows an instance to process all requests. Therefore, all resources used by the action must be synchronized, which causes the problem of thread security. WebWork 2 Actions Each request corresponds to an action, so there is no thread security problem. In fact, the servlet container will generate many Object, which is a request to produce many Object does not prove to have too much impact on performance. Now the Web container is handled such a servlet. Servlet relies on Struts to deal with ServletRequest and servletResponse. So this layer can't get a Server container. ServelTRequest may be used by Context of the Web layer. WebWork2 Every Action does not rely on any layer and any container. They use request and response to pass ActionContext, so this separation of logical layers is important. Test Because each Action of Struts must use Request and Response so they must be tested through the web level. This leads to many tests Struts to pass through the web container (although there are many test methods Cactus Mock, etc.). The webwork Action can be given a certain attribute. Optional can be performed. At the same time, you can use a Mock instance to test, not by launching a web container. The FormBean Struts requires a FormBeans for each form. It doesn't matter how much Dynabeans actually do. Unable to deal with existing models. WebWork can dynamically collect Web data and then assign a value to bean. At the same time it can also use the FormBean mode. WebWork2 also allows existing ModelDrvien for import processing. Ability to handle it like processing Action's own properties. The front end Expression Language Struts uses the JSTL EL (JSP2.0) to obtain data. The above processing is very weak in collection. The webwork front end can use JSTL to use a variety of expressions. Such as: Velocity FreeMaker Jspparer XML, etc. WebWork2 uses ONGL to create a valueStack to collect data types Struts formans put all the data as a String type. Get a type you need and then show it to the user. WebWork2 data is converted into a type in Java. This is automatically converted according to the type of form. Then operate these beans very convenient. When processing Struts after Action execution, the Struts processing Action is class-based hierarchies, it is difficult to operate before and after Action processing. WebWork2 allows you to handle Action can pass through Interceptor, or other operations are performed before or after each ACTION process. Verification Processing Because Struts's FORMBEAN is considered a String type. Many types of authentication are processed for type conversion.

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

New Post(0)