Java Web entry, from Java Web entry to proficient
NOTE Information
Review:
Common css styles:
Border
Background
Padding
Margin
Float
Position positioning top left determines the position of the div in the page. The two values can be negative.
Css + div Layout
Css + div + table is divided by div into blocks first, and then neatly arranged by table.
Drop-down list: stacked layout effect, div + css positioning, make this list floating on the page, (popwindow Android)
Embedded framework: iframe
Iframe can refresh the part of the page layout.
Src and name are used together.
Web development:
The developed program is placed on the web server (this is an application software), and the program must comply with http specifications.
Web Server Directory content.
Bin: the start and stop commands of the server.
Config: global configuration information of the server and application configuration.
Lib: contains java classes and web APIs used in web applications.
Logs: log files generated by server applications
Temp: temporary files generated by the server during execution (for the whole server)
Webapps: publish your web application here
Work: cache files generated by applications running on the server and corresponding cache data (of a Program)
Find the path:
F: \ xampp \ tomcat \ conf
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8"/>
URIEncoding = "UTF-8" indicates that Chinese character encoding is supported.
Web programs can be created in the following ways:
Manual creation and automatic IDE Creation
Need to know before
Directory structure of Web applications:
1. virtual directory:
A) web pages (html, images, etc)
B) JSP
C) WEB-INF (folder)
I. classes (class, *. class format)
Ii. lib (library, *. jar format)
Iii. Custom tags
Iv. web. xml deployment description
[The content in the deployment file must at least include:
<? Xml version = "1.0" encoding = "UTF-8"?> <Web-app version = "2.5" xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> </web-app> <! -- This is some basic description information. -->
]
The red font is mandatory in a project to identify it as a web application.
So now we can manually create a web application according to the above structure.
Step 1:
Go to the webapps directory of tomcat and create a project named WebAppByHand.
(Path: F: \ xampp \ tomcat \ webapps \ WebAppByHand)
Step 2:
Create a required file (and folder ):
A. Create a folder and rename it: WEB-INF
(Path is: F: \ xampp \ tomcat \ webapps \ WebAppByHand \ WEB-INF)
B. Go to the WEB-INF and create a notepad file named web. xml
(The current file is saved in the: F: \ xampp \ tomcat \ webapps \ WebAppByHand \ WEB-INF directory .)
C. Use the editing tool (for example, Notepad ++) to open web. xml, copy the following content to web. xml, and save it.
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"></web-app>
We will introduce the specific meanings of these content in detail later.
Step 3:
We also need a page for browsing.
A. Create a txt file named MyWebPage.html.
B. Use the editing tool (for example, Notepad ++) to open
C. Enter the following text:
Welcome to my first web Page! Wahaaa !~
To view the first network application, you need to enable the server:
Enter: F: \ xampp \ tomcat \ bin
Execute startup. bat
Wait.
Step 4:
Open your browser:
Enter http: // localhost: 8080/WebAppByHand/MyWebPage.html in the address bar.
Then you can see the corresponding results.
Method 2: Use myeclipse for automatic creation:
Step 1:
Create a project:
File-> New-> Web Project
Input name: MyFirstWeb
We can delete jsp because we want to create a static webpage.
Step 2:
Create a web page for browsing:
Right-click WebRoot-> new-> HTML (Advanced Templates)
Then you can edit it. For example, enter Hello and welcome again.
Step 3:
What we need to do is release.
There are two ways to publish: (there are two ways to view, there are two ways to publish. Using the integrated environment of myeclipse, you can view and publish data in three ways. However, an integrated environment can only be used for testing and cannot implement real release. It is just a virtual release .)
The first type is manual release.
File-> Export->
Find WAR file
To facilitate searching, we can locate the path to the desktop.
Click finish:
Then you can find MyFirstWeb. war on the desktop,
Cut copies:
F: \ xampp \ tomcat \ webapps path.
Shut down the server.
Click F: \ xampp \ tomcat \ bin shutdown. bat
Then, click startup. bat of F: \ xampp \ tomcat \ bin.
Go back to the F: \ xampp \ tomcat \ webapps directory.
An extra MyFirstWeb folder is displayed. It is automatically parsed by the tomcat server. That is to say, when we submit a war file to the webapps directory, as long as we restart the server, tomcat will automatically help us update the war file as a web program that can be browsed.
Step 4:
Browse
Open your browser and enter:
Http: // localhost: 8080/MyFirstWeb/MyHtml.html
You can browse the web program we just wrote.
Method 2:
In the above box, find
Deploy myeclipse j2ee project to server.
Click this button.
Click Add.
Currently, this is an insert page. here we need to know the version issue.
Version.
JavaEE6.0 corresponds to tomcat 7.
Only 14.6 MB is really small and light.
Through Server, we can see the servers that provide services.
However, because no configuration is available, there is no server that can support our operations.
Click: Edit server connectors...
Then we can find the path we just extracted:
Browse [here remember to check Enable .]
Select the upper-level directory to bin.
Click OK and apply OK. Three buttons.
(If Tomcat 7.x is not displayed in the Server drop-down list, close the current window and click Add to refresh)
Tomcat 7.x appears, and click Select.
Finish
Deployed successfully. Click OK.
Then you can
Run on server
Click the triangle symbol in the drop-down list, find and click tomcat 7.x, and then click start.
If you see the log information (especially the date) output by the console (in tons), it means you can access it in a browser.
Then enter:
Http: // 192.168.4.171: 8080/MyFirstWeb/MyHtml.html
Complete the access.
This is the IP address of my network here ~.
This is the second deployment and viewing method.
The third method is only used for testing and cannot be deployed. However, web pages cannot be viewed without deployment. Therefore, this is a virtual server integrated with myeclipse.
That is, the other servers we just saw in the server menu.
For example, myser ser tomcat 7.
Run on server to myEclipse tomcat7, and then click the small server button. You can view it.