Using JBuilder to develop struts

Source: Internet
Author: User
Tags config prepare

First, JBuilder support for Struts

JBuilder provides a graphical user interface to simplify the editing and setting of component file Struts-config.xml, in addition, JBuilder the Web pages in the Object Gallery dialog box to provide four of wizards to simplify the struts development process.

Struts Converter Wizard:

You can specify HTML or general JSP files to automatically generate JSP files using the Struts Tag libraries.

Actionform Wizard:

Can import JSP file generation inherits from Actionform, or custom attributes (property) generation inherited from Actionform, and so on, the class can choose whether to automatically complete struts-config.xml corresponding settings.

Action Wizard:

Can be inherited from the Action and so on, set a matching JSP file, effective range (scope) and automatically complete struts-config.xml corresponding settings.

JSP from Actionform Wizard:

The JSP file using Struts Tag libraries can be automatically generated by the specified actionform.

In addition to the wizard above, JBuilder can help developers automatically set up Web.xml deployment profiles so that the JSP uses struts to customize the Tag libraries.

Second, use JBuilder to develop the example of struts

Here's an example of developing a simple WEB application to help you understand the struts Framework. This WEB application allows the user to enter two separate strings, and the two strings are concatenated and displayed on the Web page. Because the processing logic is too simple, in this instance we intend to complete two string concatenation actions directly in the action that acts as the controller role, and therefore do not use the JavaBean or class that acts as the Model role to handle string concatenation.

Step one: Build the Web application

First click Select JBuilder Integrated development Environment Main Menu File | New Project ... Establish a project called Strutsdemo. Then the menu file | New ... Activate the Object Gallery dialog box and click the Web Application Wizard in the Select Web page to prepare the Web application.

The Web Application Wizard is ready to produce a WAR for this Web application. The deployment Profile Web.xml,war is a standard file format used in Java EE specifications to simplify the deployment complexity of Web applications. We named demo for this Web application and will later produce the file named Demo.war when compiling this project for ease of deployment, in this Web application because it will use the Tag libraries of Struts, so the Jsp/servlet framework s in the Struts 1.0, while JBuilder will automatically set the Web.xml.

Step Two: Create a custom Actionform class

The Struts Framework does not limit the development sequence of MVC three, since at this time we are not ready to enter the HTML or JSP of the two strings, so we first set up the Actionform class of storing the information, then produce the Action class that plays the Controller role, and finally Generated by the Actionform class JSP file, you can adjust the order according to the situation to adapt to the actual case. Click on the Select Object Gallery dialog Web page actionformwizard can produce custom Actionform class, Actionformwizard can be divided into three steps: The first step the wizard automatically detects the previously built WEB application dem O, we modify the custom Actionform name from the preset untitled1actionform to Myactionform, then press the Next button to enter the second step. The second step in accordance with the requirements of the future JSP page required to display and input fields into the field definition list box, if the responsible for the Web page art professionals have been ready to input JSP pages, can also press ADD from JSP ... button directly, jbuilder resolves this JSP file to produce a field definition table. In this case, because the JSP file is not ready for entry, you must add the required fields yourself. We prepare three fields in advance for this Web application, Fielda and FIELDB can store the input string, Fieldresult can be placed after two strings connected. When the setting is complete, press the Next button to enter the third step.

Does the Step three dialog box prompt you to add myactionform to the Struts-config.xml component file? Do you need to create a reset method? You can press the Finish button according to the default value.

At this point Actionform Wizard has automatically generated Myactionform.java files inherited from Actionform, and if we do not intend to implement the Validate method of data verification, we do not need to write any program code at all.

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.