当前位置: 代码迷 >> Java Web开发 >> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
  详细解决方案

java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.

热度:965   发布时间:2016-04-17 16:02:08.0
JSP连接 MS SQL 问。
HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:572)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

java.io.UTFDataFormatException:   Invalid   byte   1   of   1-byte   UTF-8   sequence.
org.apache.jasper.xmlparser.UTF8Reader.invalidByte(UTF8Reader.java:620)
org.apache.jasper.xmlparser.UTF8Reader.read(UTF8Reader.java:491)
org.apache.jasper.xmlparser.XMLEncodingDetector.load(XMLEncodingDetector.java:999)
org.apache.jasper.xmlparser.XMLEncodingDetector.skipString(XMLEncodingDetector.java:950)
org.apache.jasper.xmlparser.XMLEncodingDetector.scanXMLDecl(XMLEncodingDetector.java:1208)
org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:120)
org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:108)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:304)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:169)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.5.20   logs.


--------------------------------------------

Apache   Tomcat/5.5.20


  <html>
   <body>
   <% Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
   String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs ";
   //pubs 为你的数据库的
   String user= "sa ";
   String password= "admin ";
  相关解决方案