简体   繁体   中英

calling normal java class from servlet

每当我尝试从servlet(从其他项目)访问普通的Java类时,它都会给我classNotFound异常,任何解决此问题的想法都应事先感谢

You need to make sure that the class is available to the servlet container. How you do that will partly depend on exactly what servlet container you're using, but you could always put the jar file in WEB-INF/lib or the class file in WEB-INF/classes (under the right folder structure of course).

Hopefully your servlet container documentation will give more details - for example, the Tomcat 6.0 documentation includes this page which gives details about exactly where Tomcat looks for classes.

You should also make sure that your class includes a package statement. I don't believe that Tomcat looks kindly on classes in the default no-package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM