Although it is a very early article, the entry is still very good, from the shallow depth, the example begins very simple, as long as you look at the code carefully, there are still many harvested.
First: [Chinese] Your first Struts application
http://www.fawcette.com/china/Articles.aspx?id=123&oon=old
Simplified everything can be simplified, just give a simple landing, verification, and exit. Note the simplest usage of Action (although irregular), and several XML files that need to be configured. When you see the source code, it is advised to look at it with the next article.
==========================
Second: [Chinese] Struts application process control
http://www.fawcette.com/china/Articles.aspx?id=134&oon=old
Tell you how to run the first program and make more detailed analysis.
==========================
Article 3: [Chinese] Optimize your Struts app with ActionForward
Http://www.fawcette.com/china/Articles.aspx?id=135&oon=old
That is to introduce ActionForward, it is recommended to modify itself on the first application, and deepen the impression.
==========================
Article 4: [Chinese] Build a beautiful Struts application with ActionMapping
Http://www.fawcette.com/china/Articles.aspx?id=136&oon=old
Several features that simplify programming and improve flexibility in Struts:
1. In the Action tag, you contain a FroWard tag for action jump. use
Mapping.findforward (Name); 2. Configuring the following tab in Struts-Config to implement direct jump.
http://www.fawcette.com/javapro/2002_10/online/servletsjsp_bkurniawan_10_15_02/
Introduced Struts ActionForm
To use ActionFrom, you must complete the following steps:
1. Create a class corresponding to the form of the JSP, inheriting the Actionform class.
2. Configure struts-config.xml from-bean, for example:
1. In the form, the content GET / SET method (Eclipse can automatically generate these methods, more convenient. Eclipse3.1.)
2. Reset method for overloading ACTIONFORM. (Automatically call before passing it to the Action class)
3. You can overload the Validate method. (Automatically call before passing it to the Action class)
Get data in the form by the following type statement in ActionFrom
String username = (loginform) form .getusername ();
The ActionFrom type object is passed, and it needs to be converted to the type.
Form submitted to Actionform processes
FORM POST to Server -> ActionServlet Find the corresponding action-> Find the instance according to the name property in the action of "/ login" in struts-config, and is not created. Assign the content in the Form to this example-> Passing to ActionForm
================================ English] GRACE Under Errors
Http://www.fawcette.com/javapro/2002_10/online/servletsjsp_bkurniawan_10_28_02/
Struts mainly uses two classes to handle error ActionError and ActionerRors, the next one is the previous collection. ActionError inherited org.apache.struts.Action.actionMessage. There are 6 constructor.
After returning ActionerRors in ActionFrom, ActionerRRORS will access the associated JSP page.
1. For processing in the action, as shown below:
ActionerRORS ERRORS = new actionerrors (); errors.add (actionerroS.Global_ERROR, New ActionError ("InvaliDuser", "Invalid User Name and / or Password."); SaveerRors (Request, Errors);
2. The display error message an actionerRors object in the JSP page will be stored in the HttpRequest object, and you can read it. These things are usually used with Struts Taglib, and you will see how to implement it. Example: (the Struts used by the original code is low, some methods can not be used in the new version of Struts: such as actionerrors.global_message, ActionerRors.empty ()) has not been debugged since now, and later change to use Titles to display errors, intend This part will be empty and then change again.
<% // displays Error Messages, IF ANY
ActionErrors actionErrors = (ActionErrors) request.getAttribute (ActionMessage.GLOBAL_MESSAGE); if (actionErrors = null && actionErrors.isEmpty ()!!) {Out.println (actionErrors.size () "error (s) found
. "); Iterator errors = actionerrors.get (); while (Errors.hasNext ()) {ActionError ActionError = (Actionerror) errors.next (); string errorMessage = (String) [0]; Out.println ("-" ErrorMessage "
");} out.println ("
==========================
Seventip: [Chinese] HTML tag library series provided using Struts
1. Improve development speed with label library
http://www.fawcette.com/china/Articles.aspx?id=253&oon=old
Introduced 3 labels in the simplest HTML, for example:
Width = "200" alt = "Company logo" /> 2. Learn Struts and Form-related labels http://www.fawcette.com/china/Articles.aspx?id=255&oon=old Several labels corresponding to each element in Form 3. Use the HTML tag library provided by Struts http://www.fawcette.com/china/Articles.aspx?id=256&oon=old An example, but the Struts version issues, running Struts-Config.xml on Struts 1.2, there is a problem with the resource file mode, refer to Struts-Blank to change no problem. PS: If a javax.servlet.ServletException: Cannot Find ActionMappings or actionformbeans collection error can refer to this first resolution http://blog.9cbs.net/maxway/archive/2005/02/03/278596.aspx