Prerequisite Resources Download: webwork-2.1.7. First download the latest WebWork package from Https://webwork.dev.java.net/servlets/ProjectDocumentList and unzip it. Open the Unzip directory and you will see the following files and directories: Webwork-2.x.jar, of course, is Webwrok. Latest released Jar package Webwork-example.war is a representative example of Webwrok, and mastering it is a shortcut to improve your WebWork skill level. Webwork-migration.jar provides a class file for quickly porting a 1.x version to a 2.x version documentation for the use of the Docs directory Webwrok, including API documentation, Clover documents, Unit Test (Junit) documents, etc. Lib directory webwork all the. jar packages that are used to run or compile. SRC Directory source program directory Of course, before the introduction of specific development and use, it is necessary to set up a good operating environment. First download the latest WebWork package from Https://webwork.dev.java.net/servlets/ProjectDocumentList and unzip it. Open the Unzip directory and you will see the following files and directories: Webwork-2.x.jar, of course, is Webwrok. Latest released Jar package Webwork-example.war is a representative example of Webwrok, and mastering it is a shortcut to improve your WebWork skill level. Webwork-migration.jar provides a class file for quickly porting a 1.x version to a 2.x version documentation for the use of the Docs directory Webwrok, including API documentation, Clover documents, Unit Test (Junit) documents, etc. Lib directory webwork all the. jar packages that are used to run or compile. SRC Directory source program directory The directory structure of the next full webwork hellowolrd program for Tomcat: WebApp Eva (application name) Web-inf SRC (Class) Lib The jar packages in Lib originate from: With WebWork, of course, to put its runtime jar package into the Web container can be found in the classpath, the Webwork-2.x.jar described in step 1 is placed in your deployment directory Web-inf/lib directory, while the Webwrok extract directory lib/ All. jar files under the core are also copied to the Web-inf/lib directory, which are the jar packages required to run WebWork
2. Xwork.xml Instructions Should be placed in the class directory and should be configured as follows: <! DOCTYPE xwork Public "-//opensymphony group//xwork 1.0//en" "Http://www.opensymphony.com/xwork/xwork-1.0.dtd" > <xwork> <include file= "Webwork-default.xml"/> <package name= "Example" extends= " Webwork-default "namespace="/webwork/example " <action name=" Hello "class=" Com.eva.webwork.example.HelloWorldAction, <result Name= "Success" type= "Dispatcher"; <param name= "Location" >/GREETINGS.JSP</PARAM> </result> </action> </package> </xwork > Must have <include file= "webwork-default.xml"/> sentence, webwork-default.xml file in Webwork2.1.7.jar package. 3. webwork.properties file The Webwork.properties file and the Velocity.properties file should also be placed in the SRC directory. Otherwise, the dispatcher defined for "Success" type= "Exception" will not be found. The note in the Webwork.properties file should be as follows: Webwork.locale=zh_cn Webwork.i18n.encoding=gbk #在生产环境中, should be set to False Webwork.configuration.xml.reload=false Webwork.multipart.savedir=/temp webwork.multipart.maxsize=12345 # added the Mocktag to the path of Tags, the tagdirective would search through Webwork.velocity.tag.path = Com.opensymphony.webwork.views.velocity.ui, org.displaytag.tags Webwork.xslt.nocache=false Webwork.ui.templateDir = Template Please refer to "WebWork Tutorial. doc" for meaning. Namespace is a namespace (package name) and should be unique in Xwork.xml. Each package configuration file can be individually The <include file= "package name. xml"/> form is included in the Xwork.xml file. When accessed through the web, it should be a path to the namespace, such as the previous configuration, under the EVA application, the Web root path should be http:// 127.0.0.1:8080/eva/, when you want to access hello.action, the access address should be: http://127.0.0.1:8080/webwork/example/hello.action, which means: The Web Access path should be consistent with the "namespace" attribute in the <package/> tag in the xwork.xml configuration file, where a xwork.xml can contain multiple <package/> tags, but the package The value of Name= "" should be unique. Therefore, it is recommended that JSP pages be stored with class files in real-world development. For example, the JSP page of the Contract management module in the HJCM application is stored in the [hjcm]web application's root directory/hjcm/contract/xxxx.jsp, then the contract class file is processed accordingly, is based on the package named Hjcm.contract.XXXX.java, the Web-inf can be established under the corresponding Hjcm.contract.xml file, the package is used in the action configured in the file, The file is then added to the total Xwork.xml file as follows: Xwork.xml <! DOCTYPE xwork Public "-//opensymphony group//xwork 1.0//en" "Http://www.opensymphony.com/xwork/xwork-1.0.dtd" > <xwork> <!--Include webwork defaults (from WebWork JAR). -
<include file= "Webwork-default.xml"/>
<include file= "Suww-default.xml"/>
<include file= "Common.toolbar.xml"/>
<include file= "Dbconfig.xml"/>
<include file= "Hjcm.entry.xml"/>
<include file= "Hjcm.contract.xml"/> <include file= "Hjcm.none_contract.xml"/>
<include file= "Hjcm.settlement.xml"/> <include file= "Hjcm.expert.xml"/>
</xwork> Hcjm.contract.xml <! DOCTYPE xwork Public "-//opensymphony group//xwork 1.0//en" "Http://www.opensymphony.com/xwork/xwork-1.0.dtd" > <xwork> <package name= "contract" extends= "Webwork-default" namespace= "/hjcm/contract" > <action name= "getList" class= "Com.supporter.prj.hjcm.contract.ContractListAction" > <result name= "Success" type= "Dispatcher" > <param name= "Location" >/hjcm/contract/contract_list.jsp</param> </result> <interceptor-ref name= "params"/> </action> <action name= "edit" class= "Com.supporter.prj.hjcm.contract.ContractAction" method= "edit" > <result name= "Success" type= "Dispatcher" > <param name= "Location" >/hjcm/contract/contract_detail.jsp</param> </result> </action> ...... ...... ...... </package> </xwork> Be sure not to forget the following configuration when building Web. xml: <?xml version= "1.0" encoding= "UTF-8"? <! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.3//en" "Http://java.sun.com/dtd/web-app_2_3. DTD " <web-app> <display-name>my webwork application</display-name> <servlet> <servlet-name>webwork </servlet-name> <servlet-class> Com.opensymphony.webwork.dispatcher.ServletDispatcher </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name> Webwork</servlet-name> <url-pattern>*.action</ Url-pattern> </servlet-mapping> <taglib> <taglib-uri>webwork</taglib-uri> <taglib-location>/WEB-INF/webwork.tld</taglib-location> </taglib> <taglib> <taglib-uri>benchmark</taglib-uri> <taglib-location>/WEB-INF/taglibs-benchmark.tld</taglib-location> </taglib> <taglib> <taglib-uri>c</taglib-uri> <taglib-location>/WEB-INF/c.tld</taglib-location> </taglib> </web-app> The Web. xml file should be placed directly in the Web-inf directory. |