If you are not using any IDE, just write it in your favorite text editorCodeAnd manually deploy it to webapps/, you will often encounter the error "class cannot be reloved to a type. Solution:
1. Check whether your. Class file is in the/WEB-INF/classes/directory. If not, create the desired directory and put it in.
2. if the location of the. Class file is correct, the problem of the package is also handled, but still cannot find the class, then there is only one reason-there is no web. xml file under the WEB-INF directory. Without this file, Tomcat will not go to the WEB-INF/classes/to find your class even if you put your. Class in the correct position... Therefore, manually create web. xml and add the following code: (Tomcat 1.7 is used)
<? XML version = "1.0" encoding = "ISO-8859-1"?> <Web-app 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_3_0.xsd" version = "3.0" metadata-complete = "true"> </Web-app>
Now the problem is solved.