zoukankan      html  css  js  c++  java
  • resin web项目的 编码问题

    问题描述:

      服务器迁移,迁移以后Linux系统编码由 UTF-8 变成了GBK !!!

      导致在resin 中运行java web项目,调用 http 接口,解析http 接口的返回内容

      如:xml 时,出现奇怪的(xml 中还有中文)编码错误。(底层使用dom4j 解析xml)错误如下:

    org.dom4j.DocumentException: Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.
    	at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    	at org.dom4j.io.SAXReader.read(SAXReader.java:343)
    

      解决办法:设置resin运行环境的编码,配置如下:

    <jvm-arg>-Dfile.encoding=UTF-8</jvm-arg>

    重启resin,产看jvm  日志,看到  UTF-8 说明配置成功。

    ==> log/jvm-default.log <==
    [19:34:59.189] {main} 'select-manager' requires Resin Professional.  See http://www.caucho.com for information and licensing.
    [19:34:59.190] {main} 
    [19:34:59.190] {main} Linux 2.6.18-164.el5 amd64
    [19:34:59.190] {main} Java(TM) SE Runtime Environment 1.7.0_71-b14, UTF-8, zh
    [19:34:59.190] {main} Java HotSpot(TM) 64-Bit Server VM 24.71-b01, 64, mixed mode, Oracle Corporation

      end ~

      具体技术原因不详,望高手解决~

  • 相关阅读:
    MVC Form
    The way to learn english
    Test FastThree
    C#中Trim()、TrimStart()、TrimEnd()的用法
    c# Dictionary 简介
    visual studio快捷键大全
    ASP.NET MVC 中 ActionResult
    MVC4中使用 Ninject
    MVC Chapter 12 Overview of MVC Projects
    ASP.NET Razor
  • 原文地址:https://www.cnblogs.com/web1992/p/4586865.html
Copyright © 2011-2022 走看看