In this project development, the tomcat version of the runtime environment has been upgraded from 5.5.12 to 6.0.18. If you find that the previous project cannot run, an error will be reported when you access a very simple JSP, saying that compilation is not possible, the error is: only a type can be imported. com. xxx. xxx. xxx resolves to a package, which means that the class referenced on your JSP page does not exist, but it runs well in the old version, in addition, the JSP access under the root directory of the Project is normal, and an error is reported under the subdirectory. After Google, it is found that this is a change in the new version of Tomcat, that is, if context is not specified, every sub-folder will be Tomcat as an independent virtual application, so the JSP page under each sub-folder access, will find the class in the WEB-INF in its same layer, of course, this cannot be found. It can only be accessed by JSP files in the root directory.
Solution: In fact, this was caused by nonstandard writing when I wrote the tomcat configuration file. The host information code in the previous server. xml file is as follows:
<Host name = "www.local.com" appbase = "D: // projects // mywebsite // webcontent "unpackwars =" true "autodeploy =" true "xmlvalidation =" false "xmlnamespaceaware =" false ">
<Alias> 192.168.1.43 </alias>
<Context Path = "" docbase = "" reloadable = "true">
<Logger classname = "org. apache. catalina. logger. filelogger "directory =" logs "prefix =" www.local.com _ log. "suffix = ". TXT "timestamp =" true "/>
</Context>
In this case, the docbase In the context is empty, and the file path is specified by the appbase in the host, so Tomcat considers that there is no application in your site, each folder is automatically processed as a virtual application. The modified code snippet is as follows:
<Host name = "www.local.com" appbase = "" unpackwars = "true" autodeploy = "true" xmlvalidation = "false" xmlnamespaceaware = "false">
<Alias> 192.168.1.43 </alias>
<Context Path = "" docbase = "D: // projects // mywebsite // webcontent" reloadable = "true">
<Logger classname = "org. apache. catalina. logger. filelogger "directory =" logs "prefix =" www.local.com _ log. "suffix = ". TXT "timestamp =" true "/>
</Context>
We can see that the appbase is no longer specified in the host, but an application is created under the host. The file path of the application is specified through docbase, so that the class cannot be found.
PS: the problem of Tomcat seems to have started from 5.5.28. I remember that a similar problem occurred when I tried to upgrade Tomcat before, but there was no time to solve it, the problem persists until now.