用jacob. 先到官方网站上去下载:http://sourceforge.net/project/showfiles.php?group_id=109543&package_id=118368 jacob.zip.,下载之后解压,把jacob.jar放到项目/web-inf/lib下面。把jacob .dll放到c:/windos/system32/以及java/jdk*.*/jre/bin下面。这样就算是配置完成了。
在main函数下运行没问题
通过页面一运行出现如下异常
- org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665) at java.lang.Thread.run(Thread.java:619) Caused by:
- java.lang.NoClassDefFoundError: Could not initialize class com.jacob.activeX.ActiveXComponent at com.yigou.comm.WordUtil.ChageFormat(WordUtil.java:22)
- at com.yigou.web.actions.CategoryAction.uploaddoc(CategoryAction.java:376) at com.yigou.web.actions.CategoryAction.uploadfile(CategoryAction.java:322)
- ... 74 more
解决办法: 把jacob.dll也放到tomcat下的bin目录
转自:http://ch-dj.iteye.com/blog/1703419