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 ~

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

  • 相关阅读:
    异步请求模板和数据
    关于线上js报错问题的思考
    标准web浏览器的组件
    监控图片加载的方法
    图片轮播
    jQuery的一些小技巧()
    setTimeout/setInterval伪异步
    linux/windows java jdk环境配置
    iOS pod 第三方 unrecognized selector sent to instance
    上海4
  • 原文地址:https://www.cnblogs.com/web1992/p/4586865.html
Copyright © 2011-2022 走看看