Eclipse-download, install and configure Tomcat to deploy web projects

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
insert image description here

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.
**Bold style**

configure tomcat

Tomcat download address

1. Open Eclipse, click the "Window" menu, and select "Preferences".

insert image description here

2. Click the "Server" option and select "Runtime Environments".

insert image description here

3. "Add" to add Tomcat. Because I downloaded 8.0.33 from tomcat, so I just choose 8.0 here.

insert image description here

4. "Next", select the Tomcat path you installed.

insert image description here

5. Complete.

insert image description here

Create a web project

1、File->Dynamic Web Project

insert image description here

2. Enter Project name, Target runtime select the one we just created

insert image description here

3、Next

insert image description here

4、finish

insert image description here

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

insert image description here

2. Select our configured Tomcat, Next

insert image description here

3、Finish

insert image description here

4. The result of the following access is 404, because we have not added a home page.

insert image description here

5. Right click on WebContent and create index.jsp

insert image description here

6. Write some text casually

insert image description here

7. Repeat 1234, and the interface is displayed.

insert image description here

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 &quot;%r&quot; %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.

Guess you like

Origin blog.csdn.net/changhuzichangchang/article/details/114600153