Webwork2 tutorial (Chinese version) (2)

zhaozj2021-02-12  182

2. Establish a web application

(1) Here you assume that you install the servlet container and know how to create a web application; if you don't know, it is recommended to learn Apache Tomcat (a free servlet container in the Apache Jakarta project);

(2) Copy the required runtime (web-2.1.jar and lib / core / *. Jar) to the web-INF / lib folder of the web application;

(3) Configure web.xml, xwork.xml and validators.xml files as follows;

(4) Web.xml looks like the following:

"http://java.sun.com/dtd/web-app_2_3.dtd">

My WebWork Application

Webwork

com.opensymphony.Webwork.dispatcher.servletdispatcher

1

Webwork

*. action

Webwork

/web-inf/lib/webwork-2.1.jar

To use WebWork, you must register servletdispatcher and map to * .ACTION; as an option, if you want to use the WebWork tags, you want to declare the webwork's Taglib description;

(5) Create a webwork profile xwork.xml in the web-inf / class directory, below is a configuration framework (will add content after the tutorial):

"http://www.opensymphony.com/xwork/xwork-1.0.dtd">

This is two things:

l Import the configuration information of WebWork-Default.xml (in WebWork-2.1.jar), including the default configuration of the WebWork application;

l Define the Package named Default, registration for Actions, Results, and Interceptors; this package inherits webwork-default to inherit the definitions of definitions;

(6) Create validators.xml in a web-inf / class directory. Includes the following:

1.0 // en "" http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd ">

Class = "com.opensymphony.xwork.validator.validators.requiredfieldvaliDator" />

Class = "com.opensymphony.xwork.validator.validators.RequiredStringValidator" />

Class = "com.opensymphony.xwork.validator.validators.IntrangefieldValidator" />

Class = "com.opensymphony.xwork.validator.validators.dateRangefieldvaliDator" />

Class = "com.opensymphony.xwork.validator.validators.expressionValidator" />

Class = "com.opensymphony.xwork.validator.validators.fieldExpressionValidator" />

Class = "com.opensymphony.xwork.validator.validators.emailvalidator" />

Class = "com.opensymphony.xwork.validator.validators.URLVALIDATOR" />

Class = "com.opensymphony.xwork.validator.validators.conversionerrorfieldvaliDator" />

This file defines valid Validators that can be used.

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

New Post(0)