First: Tomcat and HelloWorld

zhaozj2021-02-16  47

Serious warning: People who know Tomcat should not look down

Opening white: relatively boring, quite tasteless

here we go

what do you need?

JDK and Tomcat

My version: J2SDK

1.4.1

And Tomcat-4.1.18

What, don't have these two stuff? Then please don't look down, hurry to go or go to email.

Installation and configuration

Put your JDK, how is your D disk? D: / j2sdk

1.4.1

Let's decompress Tomcat, and put it on D. D: / Tomcat-

4.1.18

Set your system environment variable, in order to make my fool, please forgive my Luo Wei.

My Computer - Right - Right - Advanced - Environment Variable - System Variables -

New construction

Variable name: java_home

Variable: D: / J2SDK

1.4.1

edit

Variable name: Path

Variable: D: / J2SDK

1.4.1

/ bin /; in the forefront

OK, I'm ok.

start up

In your D: / Tomcat-

4.1.18

/ bin / Look at Startup.bat, with the mouse to point her two times, let her run it.

Enter: http:// localhost: 8080 /

see

Congratulations, your configuration work is done.

Come to HelloChina

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

Create a folder under your Tomcat, just call myone.

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

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: http:// localhost: 8080 / hello.jsp: http:// localhost: 8080 / 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.

Myone

WEB-INF

Hello.jsp

Classes

Lib

Web.xml

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

New Post(0)