Because a tomcat project is created in eclipse, it does not automatically generate a web. xml configuration file in the project directory, so you need to manually add and write it. I tried to make a servlet today, but when I wrote the configuration file, I wrote an error in the attribute name of <servlet-Name> so that an error was reported during browsing. Only to find out some of the original details need to be noted, write down and remember.
In the Directory D: \ Tomcat 5.0 \ conf \ Catalina \ localhost of tomcat5.0, eclipse generates a counter. xml file. The Code is as follows:
<? XML version = '1. 0' encoding = 'utf-8'?>
<Context docbase = "D:/javaproject/workspace/counter" Path = "/counter" reloadable = "true" workdir = "D: \ javaproject \ workspace \ counter \ work">
</Context>
You should note that the path value is "/counter", which corresponds to the Web created manually in the D: \ javaproject \ workspace \ counter directory. servlet-Name: Counter in the XML file
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype web-app public "-// Sun Microsystems, Inc. // DTD web application 2.3 // en"
Http://java.sun.com/dtd/web-app_2_3.dtd>
<Web-app>
<Servlet>
<Servlet-Name> counter </servlet-Name>
<Servlet-class> com. counter1servlet </servlet-class>
</Servlet>
<Servlet-mapping>
<Servlet-Name> counter </servlet-Name>
<URL-pattern>/Counter </url-pattern>
</Servlet-mapping>
<Welcome-file-List>
<Welcome-File> counter </welcome-File>
</Welcome-file-List>
</Web-app>
I used xmlspy to write this file. It was written fast and I didn't pay much attention to it. As a result, I wrote counter into counter and browsed "http: // localhost: 8080/manager/htm ", the project cannot be found in the path column.
If you have read this article, you will also pay attention to it.
The above configuration files, mapping and welcome-file can be modified as needed, but the servlet-name should be noted, because it is also associated with the project configuration file in Tomcat.