webwork study notes ------------------------------ Author: kingfish (vc - @ sohu.com) Keywords: webwork1. 4, Tomcat5 -------------------------------------- I have learned Webwork recently, found that the information is very small. (If you have, please send me a copy, thank you), because it is an open source project, just look at the source code. The following is a note that I have finished, it is relatively simple, I hope to give it. Netizens bring a little help.
Well level, inevitable, please forgive point!
Environmental Description: Use Tomcat5.0 Webwork1.4 to open WebWork.war in Tomcat's WebApps in Tomcat's WebApps in Tomcat.
I. A servlet: Webwork.dispatcher.Servletdispatcher 1. Introduction WebWork1.4 All self-contained examples are submitted to this servlet for processing, the importance is of course self-evident. Open Webwork / Web-INF Web.xml, You can see the following configuration
...
II. Write a simple example
HelloAction.java source code
Import web.action.Actionsupport; import webwork.action.action;
Public class helloaction extends actionsupport {private string name; public helloAdition () {}
Public void setname (String name) {this.name = name;}
Public string getname () {return this.name;
Public void Dovalidation () {else if (name == null || name.length () <1) {adderror ("name", "can't be null or empty!");}}
// If you don't do other processing, you can not Override this method. By default returns Success public string doexecute () {return success;}} The compiled Class file is copied into WebWork / Web-INF / CLASSES. 2. Configure Two configuration methods Optional: (1) Configure views.properties (under WebWork / Web-INF / CLASSES) Hello.Artion = helloActionHello.input = helloinput.jsphello.success = hellosuccess.jsphello.rror = HelloError.jsp
(2) Configuring Actions.XML (under WebWork / Web-INF / CLASSES) Added an action
3. Related JSP files Establish the following four JSP files, store the directory: Webwork. (1) Index.jsp