WebWork in Layman's

Source: Internet
Author: User

Preface

This article does not have too many webwork the actual combat code details. I very much hope to be a tour guide role, leading the reader to gradually visit the WebWork features and principles. In the first chapter, we will present the 10 issues that need to be addressed in the Web tier based on the three-tier architecture, which is the longitudinal axis of this article. Around the longitudinal axis, we follow the axis of the order of the gradual description: webwork introduction, WebWork Primer, webwork principle, webwork Combat and skills, Outlook webwork the future, the final is the summary of this article. issues that need to be addressed in a three-tier architecture-based Web tier

The Web tier we are discussing here is based on a typical three-tier architecture: The Web layer, the business layer, the data tier. Therefore, we will not discuss any implementations that involve the business (business logic) layer and the data-tier functionality.

Issues that the Web tier needs to address:

1, the input of data. How to obtain request data based on stateless HTTP. How to convert the requested character data to the corresponding model object.

2. Verification of input data. How to verify the legitimacy of the input data and give an explicit error message hint.

3, the output of the data. How to present complex object structures. How to deal with complex presentation logic.

4, the data transmission and sharing. How to pass and share data between different requests or pages.

5, the process of page management. How to manage page flow in a web app.

6, the modular management. How to manage complex Web applications in a modular way.

7. Flexible and extensible architecture. How to support a variety of different presentation layer technologies. How to integrate with the various frameworks of the business layer or data layer.

8, security and access control management. How to provide the management of web-based security mechanism and resource access control.

9, the code implementation of simple and efficient. How to make development steps and code maintenance easier. How to minimize the development of intermediate links. How to strip out public functions and to assemble applications flexibly.

10, other problems. Asynchronous invocations, internationalization support, file uploads, preventing duplicate submissions, and more.

Below, let's take a look at how WebWork solves these problems.

WebWork Introduction

WebWork is a Java EE web framework developed by the Opensymphony organization dedicated to component and code reuse. WebWork is currently the latest version of 2.2.2, now webwork2.x formerly Rickard Oberg developed WebWork, but now WebWork has been split into Xwork1 and WEBWORK2 two projects, as shown in the following diagram:



Work is simple, flexible and powerful, it is a standard command mode framework implementation, and completely detached from the web layer. Xwork offers a number of core features: front-end interceptors (Interceptor), runtime form property validation, type conversion, powerful expression language (ognl–the Object Graph Notation Language), IoC (Inversion of Control relies on inverted controls) containers and so on.

WEBWORK2 is built on top of Xwork to handle HTTP requests and responses. All requests will be intercepted by its front-end controller (Servletdispatcher, the latest version is Filterdispatcher). The front controller wraps the requested data, initializes the context data, finds the action class corresponding to the request URL according to the configuration file, executes the action, and forwards the execution result to the corresponding presentation page. WEBWORK2 supports multi-view representations, and the View section can use JSP, Velocity, Freemarker, Jasperreports,xml, and so on.

The webwork we mentioned below will be for WEBWORK2, and the version used is WebWork2.2.2.

WebWork Getting Started webwork Installation

If you are just building a webwork development environment, it will be very simple:

1, go to the website http://www.opensymphony.com/webwork download the latest WebWork2.2.2 project.

2, build a Web application (this is not difficult); and copy all the jar files required to run the WebWork framework into the web-inf/lib of the Web application. These jar files can be found in the Lib/default directory in the WebWork project, that is, all the files in that directory. Of course, do not forget today's "protagonist" in the WebWork directory with the Webwork-2.2.2.jar file.

3. Configure the WebWork Front controller filterdispatcher in the Web. xml file, which is a common servlet filter. The code is as follows:

< filter >

< Filter-name > webwork </filter-name >

< Filter-class > Com.opensymphony.webwork.dispatcher.FilterDispatcher </filter-class >

</Filter >

< filter-mapping >

< Filter-name > webwork </filter-name >

< Url-pattern >/* </url-pattern >

</filter-mapping >

However, if you are using the actual project, there are some issues to be aware of during the installation process:

1, about the front-end controller. In the previous WEBWORK2 version, the front controller is Serveltdispatcher, which is a javaservlet. And now it's a filter, which will result in the use of the JSP's include in the page to contain a URL for the WebWork action request. If you really need to do this, you can use the WebWork action tag Library.

2. The suffix of the action request URL. We know that in a typical web framework, the front controller maps the request URL of a specific suffix to the corresponding action request. The front-end controller here will accept any request, but by default it maps the URL that ends the. Action to the WebWork action request. We can set our own suffix name in the webwork.properties file, and multiple suffix names can be separated by commas. Example: Webwork.action.extension=action,do

3. In the JSP page, the webwork tag library does not need to be defined in Web. XML, and is referenced directly in the page by the following code: <%@ taglib prefix = "ww" uri = "/webwork"%>

4, in the JSP page, the default "Altsyntax" is open. It is used to solve the problem of confusing strings and expression language in the tag library. Therefore, the expression language as a variable should be placed in%{}, otherwise webwork will treat it as a string.

5, if the presentation layer technology use Freemarker (WebWork official recommendation, is also my personal recommendation), if you need to use the tag library in the page, you must configure the Jspsupportservlet in Web. XML, the code is as follows:

< servlet >

< Servlet-name >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.