错误信息:
严重: Servlet.service() for servlet [servlet.ImportExcel] in context with path [/Poi_Test] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.poi.hssf.usermodel.HSSFWorkbook
解决:
如果在Servlet中调用Poi操作Excel的话需要将Poi用到的几个JAR包放在该项目的\WebContent\WEB-INF\lib 路径下
主要的是这两个jar包
poi-4.1.1.jar
commons-math3-3.6.1.jar
不然缺poi-4.1.1.jar会报
java.lang.ClassNotFoundException: org.apache.poi.hssf.usermodel.HSSFWorkbook
缺commons-math3-3.6.1.jar会报
java.lang.ClassNotFoundException: org.apache.commons.math3.util.ArithmeticUtils
在Tomcat中调试时要立即生效,需要在对应的项目目录上右键refresh刷新,或重新打开Eclipse
总之一句:Servlet.service() for servlet
web工程,需要把jar放到lib下