新葡亰496net 新葡亰编程 encoding 不对导致 XML 错误

encoding 不对导致 XML 错误

利用 XMLHTTP 将网上一个 XML 文件下载下来并保存,再利用 Microsoft.XMLDOM
分析 XML 文件,总是出错,利用浏览器浏览这个 XML 文件也出错。

前两天去一家公司面试,里面有一道XML的题目,题目没什么难的,但由于编码问题引发了一些问
题,我回来后尝试探索了一下
题目要求:把下面的XML文件用XSL转换成html表格显示出来,并按pubDate降序排列

早上在测试代码的时候遇到这个问题:

开始以为是标签错误,经过多次查证,才发现是 XML 文件缺少
encoding,同时发现
encoding 在我试验的机子上只能用 gb2312,绕了多大个弯。 

图片 1
图片 2 XML文件

F:Javajdk1.7.0_79binjava -ea -Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:Program Files (x86)JetBrainsIntelliJ IDEA 2016.1.1bin" -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath "C:Program Files (x86)JetBrainsIntelliJ IDEA 2016.1.1libidea_rt.jar;C:Program Files (x86)JetBrainsIntelliJ IDEA 2016.1.1pluginsjunitlibjunit-rt.jar;F:Javajdk1.7.0_79jrelibcharsets.jar;F:Javajdk1.7.0_79jrelibdeploy.jar;F:Javajdk1.7.0_79jrelibextaccess-bridge-64.jar;F:Javajdk1.7.0_79jrelibextdnsns.jar;F:Javajdk1.7.0_79jrelibextjaccess.jar;F:Javajdk1.7.0_79jrelibextlocaledata.jar;F:Javajdk1.7.0_79jrelibextsunec.jar;F:Javajdk1.7.0_79jrelibextsunjce_provider.jar;F:Javajdk1.7.0_79jrelibextsunmscapi.jar;F:Javajdk1.7.0_79jrelibextzipfs.jar;F:Javajdk1.7.0_79jrelibjavaws.jar;F:Javajdk1.7.0_79jrelibjce.jar;F:Javajdk1.7.0_79jrelibjfr.jar;F:Javajdk1.7.0_79jrelibjfxrt.jar;F:Javajdk1.7.0_79jrelibjsse.jar;F:Javajdk1.7.0_79jrelibmanagement-agent.jar;F:Javajdk1.7.0_79jrelibplugin.jar;F:Javajdk1.7.0_79jrelibresources.jar;F:Javajdk1.7.0_79jrelibrt.jar;I:IDEAerptargettest-classes;I:IDEAerptargetclasses;I:mavenrepositoryjunitjunit4.11junit-4.11.jar;I:mavenrepositoryorghamcresthamcrest-core1.3hamcrest-core-1.3.jar;I:mavenrepositoryorgspringframeworkspring-core3.2.2.RELEASEspring-core-3.2.2.RELEASE.jar;I:mavenrepositorycommons-loggingcommons-logging1.1.1commons-logging-1.1.1.jar;I:mavenrepositoryorgspringframeworkspring-beans3.2.2.RELEASEspring-beans-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-jdbc3.2.2.RELEASEspring-jdbc-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-tx3.2.2.RELEASEspring-tx-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-web3.2.2.RELEASEspring-web-3.2.2.RELEASE.jar;I:mavenrepositoryaopallianceaopalliance1.0aopalliance-1.0.jar;I:mavenrepositoryorgspringframeworkspring-aop3.2.2.RELEASEspring-aop-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-context3.2.2.RELEASEspring-context-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-expression3.2.2.RELEASEspring-expression-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-orm3.2.2.RELEASEspring-orm-3.2.2.RELEASE.jar;I:mavenrepositoryorgspringframeworkspring-context-support3.2.2.RELEASEspring-context-support-3.2.2.RELEASE.jar;I:mavenrepositoryorgapachestrutsstruts2-core2.3.14.2struts2-core-2.3.14.2.jar;I:mavenrepositoryorgapachestrutsxworkxwork-core2.3.14.2xwork-core-2.3.14.2.jar;I:mavenrepositoryorgfreemarkerfreemarker2.3.19freemarker-2.3.19.jar;I:mavenrepositoryognlognl3.0.6ognl-3.0.6.jar;I:mavenrepositoryjavassistjavassist3.11.0.GAjavassist-3.11.0.GA.jar;I:mavenrepositorycommons-fileuploadcommons-fileupload1.2.2commons-fileupload-1.2.2.jar;I:mavenrepositorycommons-iocommons-io2.0.1commons-io-2.0.1.jar;I:mavenrepositoryorgapachestrutsstruts2-spring-plugin2.3.14.2struts2-spring-plugin-2.3.14.2.jar;I:mavenrepositoryorgapachecommonscommons-lang33.1commons-lang3-3.1.jar;I:mavenrepositoryasmasm3.3asm-3.3.jar;I:mavenrepositoryasmasm-commons3.3asm-commons-3.3.jar;I:mavenrepositoryasmasm-tree3.3asm-tree-3.3.jar;I:mavenrepositoryorgmybatismybatis3.2.2mybatis-3.2.2.jar;I:mavenrepositoryorgmybatismybatis-spring1.2.0mybatis-spring-1.2.0.jar;I:mavenrepositorymysqlmysql-connector-java5.1.10mysql-connector-java-5.1.10.jar;I:mavenrepositorycomcloudhopperproxoolproxool.9.1proxool-0.9.1.jar;I:mavenrepositorycomcloudhopperproxoolproxool-cglib.9.1proxool-cglib-0.9.1.jar;I:mavenrepositoryavalon-frameworkavalon-framework-api4.3avalon-framework-api-4.3.jar;I:mavenrepositoryavalon-logkitavalon-logkit2.1avalon-logkit-2.1.jar;I:mavenrepositorylog4jlog4j1.2.11log4j-1.2.11.jar;I:mavenrepositoryjavaxservletservlet-api2.3servlet-api-2.3.jar;I:mavenrepositorygeronimo-specgeronimo-spec-javamail1.3.1-rc3geronimo-spec-javamail-1.3.1-rc3.jar;I:mavenrepositorygeronimo-specgeronimo-spec-jms1.1-rc4geronimo-spec-jms-1.1-rc4.jar;I:mavenrepositorycomsdiconsjsontoolsjsontools-core1.7jsontools-core-1.7.jar;I:mavenrepositoryantlrantlr2.7.6antlr-2.7.6.jar;I:mavenrepositoryorgaspectjaspectjweaver1.5.4aspectjweaver-1.5.4.jar;I:mavenrepositorytaglibsstandard1.0.6standard-1.0.6.jar;I:mavenrepositorydwrdwr1.1.3dwr-1.1.3.jar;I:mavenrepositorybsfbsf2.3.0bsf-2.3.0.jar;I:mavenrepositorydom4jdom4j1.6.1dom4j-1.6.1.jar;I:mavenrepositoryxml-apisxml-apis1.0.b2xml-apis-1.0.b2.jar;I:mavenrepositoryjdomjdom1.0jdom-1.0.jar;I:mavenrepositoryxomxom1.1xom-1.1.jar;I:mavenrepositoryxercesxmlParserAPIs2.6.2xmlParserAPIs-2.6.2.jar;I:mavenrepositoryxercesxercesImpl2.6.2xercesImpl-2.6.2.jar;I:mavenrepositoryxalanxalan2.7.0xalan-2.7.0.jar;I:mavenrepositoryjaxenjaxen1.1-beta-8jaxen-1.1-beta-8.jar;I:mavenrepositoryorgspringframeworkspring-test4.1.6.RELEASEspring-test-4.1.6.RELEASE.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 manager.admin.AdminUserDaoTest,testFindAdminUsersByAdminId
[framework] 2016-08-15 09:39:30,002 - org.springframework.core.env.StandardEnvironment -1    [main] DEBUG org.springframework.core.env.StandardEnvironment  - Initializing new StandardEnvironment
[framework] 2016-08-15 09:39:30,005 - org.springframework.core.env.StandardEnvironment -4    [main] DEBUG org.springframework.core.env.StandardEnvironment  - Adding [systemProperties] PropertySource with lowest search precedence
[framework] 2016-08-15 09:39:30,006 - org.springframework.core.env.StandardEnvironment -5    [main] DEBUG org.springframework.core.env.StandardEnvironment  - Adding [systemEnvironment] PropertySource with lowest search precedence
[framework] 2016-08-15 09:39:30,007 - org.springframework.core.env.StandardEnvironment -6    [main] DEBUG org.springframework.core.env.StandardEnvironment  - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
[framework] 2016-08-15 09:39:30,012 - org.springframework.context.support.ClassPathXmlApplicationContext -11   [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext  - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@d809bd3: startup date [Mon Aug 15 09:39:30 CST 2016]; root of context hierarchy
[framework] 2016-08-15 09:39:30,050 - org.springframework.core.env.StandardEnvironment -49   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Initializing new StandardEnvironment
[framework] 2016-08-15 09:39:30,050 - org.springframework.core.env.StandardEnvironment -49   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Adding [systemProperties] PropertySource with lowest search precedence
[framework] 2016-08-15 09:39:30,050 - org.springframework.core.env.StandardEnvironment -49   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Adding [systemEnvironment] PropertySource with lowest search precedence
[framework] 2016-08-15 09:39:30,051 - org.springframework.core.env.StandardEnvironment -50   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
[framework] 2016-08-15 09:39:30,051 - org.springframework.core.env.StandardEnvironment -50   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Initializing new StandardEnvironment
[framework] 2016-08-15 09:39:30,051 - org.springframework.core.env.StandardEnvironment -50   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Adding [systemProperties] PropertySource with lowest search precedence
[framework] 2016-08-15 09:39:30,051 - org.springframework.core.env.StandardEnvironment -50   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Adding [systemEnvironment] PropertySource with lowest search precedence
[framework] 2016-08-15 09:39:30,052 - org.springframework.core.env.StandardEnvironment -51   [main] DEBUG org.springframework.core.env.StandardEnvironment  - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
[framework] 2016-08-15 09:39:30,060 - org.springframework.beans.factory.xml.XmlBeanDefinitionReader -59   [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [applicationContext-commons.xml]
[framework] 2016-08-15 09:39:30,134 - org.springframework.beans.factory.xml.DefaultDocumentLoader -133  [main] DEBUG org.springframework.beans.factory.xml.DefaultDocumentLoader  - Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl]
[framework] 2016-08-15 09:39:30,258 - org.springframework.beans.factory.xml.PluggableSchemaResolver -257  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/beans/spring-beans-3.0.xsd]
[framework] 2016-08-15 09:39:30,258 - org.springframework.beans.factory.xml.PluggableSchemaResolver -257  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Loading schema mappings from [META-INF/spring.schemas]
[framework] 2016-08-15 09:39:30,271 - org.springframework.beans.factory.xml.PluggableSchemaResolver -270  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Loaded schema mappings: {http://mybatis.org/schema/mybatis-spring-1.2.xsd=org/mybatis/spring/config/mybatis-spring-1.2.xsd, http://www.springframework.org/schema/jee/spring-jee-3.2.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd, http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd, http://www.springframework.org/schema/cache/spring-cache.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd, http://www.springframework.org/schema/task/spring-task-3.1.xsd=org/springframework/scheduling/config/spring-task-3.1.xsd, http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd=org/springframework/jdbc/config/spring-jdbc-3.1.xsd, http://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd, http://www.springframework.org/schema/jee/spring-jee-3.1.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/tx/spring-tx-3.2.xsd=org/springframework/transaction/config/spring-tx-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/util/spring-util-3.2.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd, http://www.springframework.org/schema/lang/spring-lang-3.2.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://www.springframework.org/schema/cache/spring-cache-3.2.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://mybatis.org/schema/mybatis-spring.xsd=org/mybatis/spring/config/mybatis-spring-1.2.xsd, http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.2.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/aop/spring-aop-3.2.xsd=org/springframework/aop/config/spring-aop-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd, http://www.springframework.org/schema/tx/spring-tx-3.1.xsd=org/springframework/transaction/config/spring-tx-3.1.xsd, http://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-3.1.xsd=org/springframework/scripting/config/spring-lang-3.1.xsd, http://www.springframework.org/schema/cache/spring-cache-3.1.xsd=org/springframework/cache/config/spring-cache-3.1.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd, http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc.xsd=org/springframework/jdbc/config/spring-jdbc-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop-3.1.xsd=org/springframework/aop/config/spring-aop-3.1.xsd, http://www.springframework.org/schema/task/spring-task-3.2.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd, http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd=org/springframework/jdbc/config/spring-jdbc-3.2.xsd, http://www.springframework.org/schema/tool/spring-tool-3.2.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd}
[framework] 2016-08-15 09:39:30,277 - org.springframework.beans.factory.xml.PluggableSchemaResolver -276  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.0.xsd
[framework] 2016-08-15 09:39:30,340 - org.springframework.beans.factory.xml.PluggableSchemaResolver -339  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/context/spring-context-3.0.xsd]
[framework] 2016-08-15 09:39:30,341 - org.springframework.beans.factory.xml.PluggableSchemaResolver -340  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Found XML schema [http://www.springframework.org/schema/context/spring-context-3.0.xsd] in classpath: org/springframework/context/config/spring-context-3.0.xsd
[framework] 2016-08-15 09:39:30,348 - org.springframework.beans.factory.xml.PluggableSchemaResolver -347  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/tool/spring-tool-3.0.xsd]
[framework] 2016-08-15 09:39:30,349 - org.springframework.beans.factory.xml.PluggableSchemaResolver -348  [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver  - Found XML schema [http://www.springframework.org/schema/tool/spring-tool-3.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-tool-3.0.xsd

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-commons.xml]; nested exception is java.io.UTFDataFormatException: Invalid byte 3 of 3-byte UTF-8 sequence.

    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:408)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at manager.admin.AdminUserDaoTest.testFindAdminUsersByAdminId(AdminUserDaoTest.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.io.UTFDataFormatException: Invalid byte 3 of 3-byte UTF-8 sequence.
    at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
    at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
    at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
    at org.apache.xerces.impl.XMLEntityScanner.peekChar(Unknown Source)
    at org.apache.xerces.impl.XMLScanner.scanComment(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanComment(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    ... 41 more

Process finished with exit code -1

 1
图片 3 <? xml version=”1.0″ ?>
 2 图片 4
<? xml-stylesheet type=”text/xsl” href=”books.xsl”
?>
 3 图片 5
< books >
 4 图片 6  
< book  id =”1″  pubDate =”20050707″ >
 5 图片 7     
< title > c# XML入门经典 </ title >
 6 图片 8     
< description > 编程人员必被的XML技能 </ description >
 7 图片 9  
</ book >
 8 图片 10  
< book  id =”2″  pubDate =”20050607″ >
 9 图片 11     
< title > XSL编程精要 </ title >
10 图片 12     
< description > 从XML到HTML </ description >
11 图片 13  
</ book >
12 图片 14  
< book  id =”3″  pubDate =”20050607″ >
13 图片 15     
< title > .NET framework框架程序设计 </ title >
14 图片 16     
< description > 框架程序设计 </ description >
15 图片 17  
</ book >
16 图片 18
</ books >

Google了一下,原因大致如下:

当时我习惯的在桌面上建立文本文件,然后手工输入:

(a) The file was intended to be UTF-8, but was incorrectly encoded;
(b) The file is in some other encoding such as iso-8859-1, but has no
XML
declaration describing its encoding, so UTF-8 has been assumed by the
XML
parser.
(c) The file has been transcoded in transit, that is, it declares
its
encoding to be UTF-8 in its XML declaration, but some software that
doesn’t
understand XML changed its encoding to something else, without
changing the
XML declaration.

标签:

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图