其中如果ne='英文字符串'那么它最后生成的是
<?xml version='1.0' encoding='GBK'?>
<new package='vne' class='TerminalService' name='__remote_object' >
<params ne='GW1' port='port1' client_type='terminal'/>
</new>
如果ne='中文'那么它最后生成的是,并且报错,说需要有</new>结束标记
<?xml version='1.0' encoding='GBK'?>
<new package='vne' class='TerminalService' name='__remote_object' >
<params ne='长途局' port='port1' client_type='terminal'/>
</n其中ne的取值是从数据库中取的,然后通过jdom生成xml
<?xml version='1.0' encoding='GBK'?>
<new package='vne' class='TerminalService' name='__remote_object' >
<params ne='GW1' port='port1' client_type='terminal'/>
</new>
如果ne='中文'那么它最后生成的是,并且报错,说需要有</new>结束标记
<?xml version='1.0' encoding='GBK'?>
<new package='vne' class='TerminalService' name='__remote_object' >
<params ne='长途局' port='port1' client_type='terminal'/>
</n其中ne的取值是从数据库中取的,然后通过jdom生成xml
看看你生成的xml文件实际的编码对不对,我怀疑并不是gbk
Caused by: org.jdom.JDOMException: The element type "new" must be terminated by the matching end-tag "</new>".: Error on line 1: The element type "new" must be terminated by the matching end-tag "</new>". at org.jdom.input.SAXBuilder.build(SAXBuilder.java:318) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:411) at com.arkco.XmlString.ToElement(XmlString.java:33) at com.arkco.RemoteObjectService.CreateService(RemoteObjectService.java:126)我就是不明白为何,代码是一样的,为何中文就生成缺少</new>,而英文,则不会出现
不是写了encoding=GBK就可以了,应该
format = Format.getCompactFormat();
format.setEncoding("GB2312");//ISO-8859-1");//GBK
format.setIndent(" ");
XMLOutputter XMLOut = new XMLOutputter(format);