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

zhaozj2021-02-16  54

Come to HelloChina

The first example of all programs introduced, I am helloWorld, let's take a Hellochian how

In your Tomcat's WebApps (all your apps in WebApps) are set up under WebApps, it's called MYOONE.

Built a folder web-infer

Two folders under Web-INF: Classes and LIB

Write it, don't ask why? If you want to run, don't write wrong.

Write hello.jsp to your Myone with your Notepad.

Hellochina

What, don't know what HTML is? Then you still learn to learn, write bad, at least understand.

Write Web.xml with your Notepad to put it under Web-INF.

PUBLIC "- // Sun microsystems, Inc.//dtd Web Application 2.2 // en"

"http://java.sun.com/j2ee/dtds/web-app_2_2.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

->

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-parser-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

Login.jsp

What, too long, write hard? Ctrl C and Ctrl V will?

What, don't understand? I have to know you?

Restart your Tomcat (it's closed, open again).

Enter your IE address bar: http: // localhost: 8080 / myone / hello.jsp

All right

See the result. That is: Hellochina.

Why, I feel too much trouble? For this simple stuff, do so many famous characters, too "turtly pants fart"? No one calls you to write a HelloWorld talented program. Don't think it's simple, learn is big! Ok, when you see the results of this example, it should be said to you: Welcome you, you have seen the door that "develops three-layer structure program with Java". Reiterate: You just see the door, I haven't gone to the door, but I don't say it. Let's continue to work hard, the priest is still behind!

This chapter later

Remember the directory structure of our first example? Be sure to put your application under the WebApps of Tomcat, and you must have web-infers in your application. Be sure to have Web.xml under Web-INF, of course, folder classes and folders under Web-INF Lib is not used yet, but you will pick up the gourd in this way. In the future, put your program's Java class in the class, put the needed JAR package in LIB.

In order to let you see the directory structure more understand, I painted a very ugly thing (cylinder representing folder, rounded rectangular representation).

Ok, I hope that your Myone program is all smooth.

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

New Post(0)