There is no nonsense: starting from 0 to develop its own BS with Java - 5.1

zhaozj2021-02-16  57

Article 5: Struts small test cattle knife

Serious warning: If you skip the upper article, I am not responsible for any problems you encountered in this article.

Opening white: First of all, I hope that you understand how Struts work. On the JSP page, when we have submitted actions (you understand when the button is pressed), the page is data (such as: text box, check box, radio box, drop basket, etc.) Automatically write into the Form, which is also obtained from Form when the page needs data. Action can obtain relevant data from the Form and can be processed, and the results of the processing are also placed in the Form.

I used to define a text box like this:

Now use Struts label library, we define a text box like this

The text box that is defined, when the submit button on the page is pressed, the content in this text box is automatically placed in the FROM, and is in a str1 property of the Form, for this, Form will define GET method and set method for this attribute

Use example to explain the problem:

The name of the project is called: User

(What hope you know where to put your user, what is in the user)

The appearance of this example is this, first of all the first page has two text boxes: enter your last name (firstname) and your name (Lastname), and a "submit" button, when pressing the button At the time, you will call another page to display the name of the name and name. If the last name or name has a "submit", turn to another warning page. I don't know if I said, "Demand" is not, let's take a look at the effect.

What do you need: Please put all the things below 1 and 2 in Web-INF, let them walk side by side, sit in flat, and in the future program, I don't say it, please consciously put them in you. Application under Web-INF

1: Struts label library file, these things if you can't find it, please give me email.

Struts-bean.tld, struts-config.xml.bak, struts-html.tld, struts-logic.tld, struts-nested.tld, struts-tiles.tld, struts-tiles.tld

2: Two XML configuration files

The content of web.xml is as follows, if I don't specifically explain it later, the content of web.xml is accurate.

Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"

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

Action

- struts1.0.x: an actioncomponentservlet

- Struts1.1: ActionServlet- No Struts: TilesServlet

->

org.apache.struts.tiles.ActioncomponentServlet ->

org.apache.struts.Action.ActionServlet

org.apache.struts.tiles.tilesservlet ->

Specify Configuration File Names. There Can Be Several CommA

Separated File Names

->

definitions-config

/web-inf/tiles-defs.xml,

/Web-inf/tiles-defs.xml

Specify Tiles Debug Level.

O: no debug information

1: Debug Information

2: More debug information

->

definitions-debug

1

Specify Digester Debug Level. This value is passed to Digester

O: no debug information

1: Debug Information

2: More debug information

->

definitions-paser-details

0

Specify if Xml Parser SHOULD VALIDATE The TILES Configuration File.

True: Validate. DTD SHOULD BE Specified in File HEADER.

False: No Validation

->

definitions-paser-validate

True

config

/Web-inf/struts-config.xml

validate

True

debug

2

detail

2

2

Action

*. do

60

Login.jsp

/web-inf/struts-tiles.tld

/web-inf/struts-tiles.tld

/web-inf/struts-html.tld

/web-inf/struts-html.tld

/web-inf/struts-bean.tld

/web-inf/struts-bean.tld

/web-inf/struts-logic.tld

/web-inf/struts-logic.tld

ZCHFIVE DATABASE Connection Pool

JDBC / ZCHFIVEDB

javax.sql.datasource

container

The contents of Struts-Config.xml are as follows, and the content of this configuration is different depending on your application, but the format will be the same.

"- // Apache Software Foundation // DTD Struts Configuration 1.1 // En"

"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

This Is The Struts Configuration File for the Example Application,

Using the proposed New Syntax.

NOTE: You Would Only Flesh Out The Details in The "Form-Bean"

Declarations if you had a generator Tool That Used Them To create

The Corresponding Java Classes for you. OtherWise, you would

Need Only the "form-bean" Element itself, with the corresponding

"Name" and "type" attributes.

->

Type = "useeraction"

Name = "Userform"

Scope = "request"

Validate = "false">

(.........)

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

New Post(0)