java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > java 解决异常utf-8

java 解决异常 2 字节的 UTF-8 序列的字节2 无效的问题

投稿:lqh

这篇文章主要介绍了java 解决异常 2 字节的 UTF-8 序列的字节 2 无效的问题的相关资料,需要的朋友可以参考下

java 解决异常 2 字节的 UTF-8 序列的字节 2 无效的问题

         最近做项目,遇到异常 2 字节的 UTF-8 序列的字节 2 无效的问题,上网找了下资料,这里记录下解决方法,有遇到同样问题的大家,可以看下

详细异常:

十二月 08, 2015 7:16:55 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [jsp] in context with path [/test] threw exception [org.apache.jasper.JasperException: XML parsing error on file org.apache.tomcat.util.scan.MergedWebXml] with root cause
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。
 at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:687)
 at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:372)
 at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1753)
 at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(XMLEntityScanner.java:497)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2710)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
 at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
 at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
 at org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:96)
 at org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:83)
 at org.apache.jasper.compiler.JspConfig.init(JspConfig.java:231)
 at org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:290)
 at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:113)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:365)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
 at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:342)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:90)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:91)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at com.huaqin.dmt.filter.Acl.doFilter(Acl.java:251)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at com.huaqin.dmt.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:38)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:744)

解决方法:

在tomcat的bin目录下有文件catalina.bat

找到这行:set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%

在它上一行加入:set JAVA_OPTS=-server -Dfile.encoding=utf-8

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

您可能感兴趣的文章:
阅读全文