Eclipse - install to deploy web project
- ExlipseDownload
- Exlipse installation
- configure tomcat
- Create a web project
- Deploy the project to the Tomcat server
-
- 1. Select the project, right click Run As->Run on Server
- 2. Select our configured Tomcat, Next
- 3、Finish
- 4. The result of the following access is 404, because we have not added a home page.
- 5. Right click on WebContent and create index.jsp
- 6. Write some text casually
- 7. Repeat 1234, and the interface is displayed.
- Digression: Context configuration in Server.xml
ExlipseDownload
The last time I used eclipse can be traced back to four or five years ago. I haven’t used it for such a long time and found that this ide has improved a lot. Eclipse now uses the installer method, as shown in the figure below, this eclipse-inst-jre-win64 file is an installer for Eclipse, about 100M. It also provides a domestic mirror, click the option to select another mirror below, choose a China mirror in the pop-up box, and the download can be completed in a few seconds.
download link
Exlipse installation
After the installer is successfully installed, he will jump to a selection interface. The versions are listed here, but the old Eclipse IDE for Java EE Developers is gone (that is, the version we developed webApp), because it has been replaced by Eclipse IDE for Enterprise Java Developers, so we just choose to install this . Be patient, the installation process is a bit long.
configure tomcat
1. Open Eclipse, click the "Window" menu, and select "Preferences".
2. Click the "Server" option and select "Runtime Environments".
3. "Add" to add Tomcat. Because I downloaded 8.0.33 from tomcat, so I just choose 8.0 here.
4. "Next", select the Tomcat path you installed.
5. Complete.
Create a web project
1、File->Dynamic Web Project
2. Enter Project name, Target runtime select the one we just created
3、Next
4、finish
Deploy the project to the Tomcat server
Our project has been created, and now it is very simple to run.
1. Select the project, right click Run As->Run on Server
2. Select our configured Tomcat, Next
3、Finish
4. The result of the following access is 404, because we have not added a home page.
5. Right click on WebContent and create index.jsp
6. Write some text casually
7. Repeat 1234, and the interface is displayed.
Deployment succeeded!
Digression: Context configuration in Server.xml
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>
<Context docBase="studentWorkDemo" path="/studentWorkDemo" reloadable="true" source="org.eclipse.jst.jee.server:studentWorkDemo"/>
</Host>
path: Specify the URL entry to access the web application. If you modify it as follows, you need http://localhost:8080/student/ to access.
<Context docBase="studentWorkDemo" path="/student" reloadable="true" source="org.eclipse.jst.jee.server:studentWorkDemo"/>
docBase: indicates the specific physical address of the Web application. You can specify an absolute path or a relative path relative to the appBase attribute. If the web application adopts an open directory structure, specify the root directory of the web application. If the web application is a war file, specify the path of the war file.
In the above example, when accessing localhost/student, the application studentWorkDemo (relative addressing) is accessed.
reloadable: If this attribute is set to true, the tomcat server will monitor the changes of the class files in the WEB-INF/classes and WEB-INF/lib directories when it is running. If any class files are detected to be updated, the server will automatically reload Load the web application. Setting the reloadable attribute to true in the development stage is helpful for debugging servlets and other class files, but this will increase the running load of the server. It is recommended to set reloadable to false in the storage stage of the Web application.