先处理一下 <%
request.setCharacterEncoding("GB2312")%>

解决方案 »

  1.   

    我已经找到了,是我又通过程序访问xml文件replace了一个字符造成的
      

  2.   

    但我想生成:
    <?xml version="1.0" encoding="UTF-8"?>
    <report xmlns="http://fitech-report.com/smis" xmlns:xsi="http://www.w3.org/2001/XMLSchema" reporttype="POINT" reportlayer="MAIN">
        <common>
            <sign>
                <fitechFiller>admin</fitechFiller>
                <fitechChecker>admin</fitechChecker>
                <fitechPrincipal>admin</fitechPrincipal>
            </sign>
        </common>
    </report>
    添加Namespace ns_xml = Namespace.getNamespace("", reportObj.getXmlns_Attr());
           Namespace ns_xsi = Namespace.getNamespace("xsi", reportObj.getXmlnsxsi_Attr());
           reportElement.setNamespace(ns_xml);
           reportElement.addNamespaceDeclaration(ns_xsi);
    后就生成了:
    <?xml version="1.0" encoding="UTF-8"?>
    <report xmlns="http://fitech-report.com/smis" xmlns:xsi="http://www.w3.org/2001/XMLSchema" reporttype="POINT" reportlayer="MAIN">
        <common xmlns="">
            <sign>
                <fitechFiller>admin</fitechFiller>
                <fitechChecker>admin</fitechChecker>
                <fitechPrincipal>admin</fitechPrincipal>
            </sign>
        </common>
    </report>这样在common节点中添加了xmlns=""是我不想要的,改怎么处理呢???谢谢