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 HTML>
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.
XML Version = "1.0" encoding = "GB2312"?>
PUBLIC "- // Sun microsystems, Inc.//dtd Web Application 2.2 // en"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
- struts1.0.x: an actioncomponentservlet
- Struts1.1: ActionServlet
- No Struts: TilesServlet
->
org.apache.struts.tiles.ActioncomponentServlet servlet-class> ->
org.apache.struts.tiles.tilesservlet servlet-class> ->
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
->
init-param>
Specify Digester Debug Level. This value is passed to Digester
O: no debug information
1: Debug Information
2: More debug information
->
init-param>
Specify if Xml Parser SHOULD VALIDATE The TILES Configuration File.
True: Validate. DTD SHOULD BE Specified in File HEADER.
False: No Validation
->
init-param>
init-param>
init-param>
init-param>
init-param>
servlet>
servlet-maping>
welcome-file-list>
web-app>
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.