Home>

Unlike myeclipse, web projects made in eclipse do not support publishing projects to a web server by default.Will be published to a directory in the workspace,Therefore, it is not possible to start tomcat externally to run web projects, only to open the server in eclipse,To run web projects. So to modify eclipse,To make good projects,Publish to tomcat server,Publish to the webapps folder on the server.This article introduces two methods;

the first method:

1. By modifying the configuration of tomcat under servers:

Show view—>server to find the tomcat that needs to be modified—>Right-click to complete a fewstep:

① Stop the tomcat server in eclipse (stop)

② delete the project deployed in the container (add and remove)

③ Clear the container related data (clean)

④Open the tomcat modification interface (open)

⑤ Find the servers location and select the second one (user tomcat installation)

⑥ Modify the deployment path to webapps

⑦Save Close

It should be noted that ①②③ must be operated,Otherwise, the following steps will be grayed out and cannot be operated.

The modified image is as follows:

2. Verify whether the modification is successful:

1. Establish a dynamic web project through eclipse;

2. Add an index.html page;

<body>
hello peace
</body>

3. Right-click on webcontent and select new->other->web->servlet:

The configuration is as follows:com.rlovep.hello.hello.java

Note that my servlet is 3.0 or higher,Can use annotations:no need to modify web.xml;

@webservlet ("/hello") //Annotation url:/hello
public class hello extends httpservlet {
 private static final long serialversionuid=1l;
protected void doget (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {
 printwriter out=response.getwriter ();
 out.println ("hello peace");
}
}

4. Right-click (add and remove) to add the project to tomcat:

5. You can see your project folder under the webapps folder on the server;(Like my httpser)

6, run tomcat can see the following figure:

Homepage:http://localhost:8080/httpser /

hello page (servlet):http://localhost:8080/httpser/hello

The second method:through the tomcatplugin plugin

1. Download the plugin and decompress it to the plugins directory under eclipse. After restarting, you will see 3 kittens, and configure the tomcat home in window->perferences->tomcat as the tomcat directory application.

2. The tomcat property configuration of the project is as follows:Main modification:tick is a tomcat project;modify the context name to the name i want

Right-click project run, run server;run the program,You can get the same results as above.

  • Previous Jquery click through book effect code
  • Next Interlacing text with JavaScript and CSS