将docx转换为html字符串时出现问题。我使用APACHE POI
InputStream is = new FileInputStream(file);
XWPFDocument document = new XWPFDocument(is);
is.close();
// 2) Prepare Html options
XHTMLOptions options = XHTMLOptions.create();
// Extract image
// 3) Convert XWPFDocument to HTML
ByteArrayOutputStream out = new ByteArrayOutputStream();
XHTMLConverter.getInstance().convert(document, out, options);
re = out.toString();
out.close();
我用 org.apache.poi.xwpf.converter.core-1.0.4.jar和org.apache.poi.xwpf.converter.xhtml-1.0.4.jar
当我运行我的应用程序时,我在控制台中出错。
SEVERE: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
cusc/cchc/util/OfficeReader.convertDocxToHtml()Ljava/lang/String; @105:
invokeinterface
Reason:
Type 'org/apache/poi/xwpf/converter/xhtml/XHTMLOptions' (current frame, stack[3]) is not assignable to 'org/apache/poi/xwpf/converter/core/Options'
Current Frame:
bci: @105
flags: { }
locals: { 'cusc/cchc/util/OfficeReader', 'java/lang/String', 'java/io/FileInputStream', 'org/apache/poi/xwpf/usermodel/XWPFDocument', 'org/apache/poi/xwpf/converter/xhtml/XHTMLOptions', 'java/io/ByteArrayOutputStream' }
stack: { 'org/apache/poi/xwpf/converter/core/IXWPFConverter', 'org/apache/poi/xwpf/usermodel/XWPFDocument', 'java/io/ByteArrayOutputStream', 'org/apache/poi/xwpf/converter/xhtml/XHTMLOptions' }
Bytecode:
0x0000000: 1212 4c2a b400 16c6 018d 2ab4 0016 b600
0x0000010: 1c99 0183 b800 59b6 005f 1400 6369 bb00
0x0000020: 6559 b800 6714 006d 6bb8 006f b700 73b6
0x0000030: 0076 8561 b800 7ab3 007e bb00 c659 2ab4
0x0000040: 0016 b700 c84d bb01 3e59 2cb7 0140 4e2c
0x0000050: b601 41b8 0144 3a04 bb01 4959 b701 4b3a
0x0000060: 05b8 014c 2d19 0519 04b9 0151 0400 1905
0x0000070: b601 574c 1905 b601 582b bb00 2d59 b201
0x0000080: 59b8 015e b700 31b2 007e b601 6113 0164
0x0000090: b601 61b6 0036 1212 b601 664c 1301 6ab8
0x00000a0: 016c 3a06 1906 2bb6 0172 3a07 b800 473a
0x00000b0: 0819 08b6 004d 3a09 1909 b600 51c0 0057
0x00000c0: 3a0a 190a 1280 b900 8202 00c0 0086 3a0b
0x00000d0: 190a b800 883a 0c19 0bb6 008e b600 923a
0x00000e0: 0d19 0c19 0d19 0bb6 0097 b900 9b01 0012
0x00000f0: a0b8 00a2 3a0e 190e 12aa 12ac b900 ae03
0x0000100: 0019 0e12 b412 b6b9 00ae 0300 190e 12b8
0x0000110: 12ba b900 ae03 0019 0e12 bc12 beb9 00ae
0x0000120: 0300 190e 12c0 12c2 b900 ae03 0019 0e12
0x0000130: c4b2 007e b900 ae03 00a7 0050 1907 04b6
0x0000140: 0176 1301 6413 017c b601 663a 0f19 0e13
0x0000150: 017e bb00 2d59 b200 7eb8 015e b700 3113
0x0000160: 0164 b601 6119 0fb6 0161 b600 36b9 00ae
0x0000170: 0300 2b19 0f13 017c 1301 64b6 0166 190e
0x0000180: b901 8001 00b6 0166 4c19 07b6 0181 9aff
0x0000190: aea7 0027 b200 2013 0121 b601 23a7 001b
0x00001a0: 4d2c b601 8412 12b0 4d2c b601 8912 12b0
0x00001b0: 4d2c b601 8c12 12b0 2bb0
Exception Handler Table:
bci [3, 413] => handler: 416
bci [3, 413] => handler: 424
bci [3, 413] => handler: 432
Stackmap Table:
full_frame(@316,{Object[#1],Object[#68],Object[#322],Object[#318],Object[#325],Object[#329],Object[#365],Object[#375],Object[#72],Object[#82],Object[#87],Object[#134],Object[#416],Object[#68],Object[#175]},{})
same_frame_extended(@393)
full_frame(@404,{Object[#1],Object[#68]},{})
same_locals_1_stack_item_frame(@416,Object[#389])
same_locals_1_stack_item_frame(@424,Object[#394])
same_locals_1_stack_item_frame(@432,Object[#397])
same_frame(@440)
我在网上搜索错误,他们说这是关于JDK的问题。我使用JDK 7.帮我解决这个错误。
全部谢谢