NutzCN Logo
问答 微信回复获取中文 convert(postData) 后乱码!
发布于 2733天前 作者 wendal 2247 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

这里是 postData 数据。

<xml><ToUserName><![CDATA[gh_8e20050bbc8d]]></ToUserName>
<FromUserName><![CDATA[o-NXlt5KV1aCSWRJ4Nub38OS1Zwg]]></FromUserName>
<CreateTime>1495527084</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[21根据]]></Content>
<MsgId>6423239916537394819</MsgId>
</xml>

转换后,打印的json是

{
   "toUserName": "gh_8e20050bbc8d",
   "fromUserName": "o-NXlt5KV1aCSWRJ4Nub38OS1Zwg",
   "createTime": "1495527084",
   "msgType": "text",
   "content": "21????",
   "msgId": "6423239916537394819"
}

这里是启动日志格式

[DEBUG] 2017-05-23 16:20:22,689 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:61) -  - Default Charset : GBK
[DEBUG] 2017-05-23 16:20:22,689 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:62) -  - Current . path  : D:\apache-tomcat-8.0.43_8080\bin\.
[DEBUG] 2017-05-23 16:20:22,690 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:63) -  - Java Version    : 1.8.0_101
[DEBUG] 2017-05-23 16:20:22,690 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:64) -  - File separator  : \
[DEBUG] 2017-05-23 16:20:22,690 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:65) -  - Timezone        : Asia/Shanghai
[DEBUG] 2017-05-23 16:20:22,690 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:66) -  - OS              : Windows 7 amd64
[DEBUG] 2017-05-23 16:20:22,690 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:67) -  - ServerInfo      : Apache Tomcat/8.0.43
[DEBUG] 2017-05-23 16:20:22,691 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:68) -  - Servlet API     : 3.1

但是cms上面录入中文都没有问题。
日志也正常。
看过其他提问,把vm paramters写为 -Dfile.encoding=UTF-8。则日志打印时候,变成Default Charset : UTF-8,但是我的日志都是乱码了

23-May-2017 16:25:12.905 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.43
23-May-2017 16:25:12.909 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Mar 28 2017 14:42:59 UTC
23-May-2017 16:25:12.909 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.43.0
23-May-2017 16:25:12.909 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 7
23-May-2017 16:25:12.909 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1
23-May-2017 16:25:12.911 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
23-May-2017 16:25:12.912 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_101\jre
23-May-2017 16:25:12.913 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_101-b13
23-May-2017 16:25:12.913 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
......
[DEBUG] 2017-05-23 16:27:08,303 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=uuid()
[DEBUG] 2017-05-23 16:27:08,337 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.uid()
[DEBUG] 2017-05-23 16:27:08,339 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.now()
[DEBUG] 2017-05-23 16:27:08,339 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.flag()
[DEBUG] 2017-05-23 16:27:08,340 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - INSERT INTO wx_msg(id,openid,nickname,type,content,replyId,wxid,opBy,opAt,delFlag) VALUES(?,?,?,?,?,?,?,?,?,?) 
    |                                1 |                            2 |  3 |   4 | 5 |    6 |                                7 | 8 |          9 |    10 |
    |----------------------------------|------------------------------|----|-----|---|------|----------------------------------|--|------------|-------|
    | 38292f4d8cc24ca2a76e9534029a5a89 | o-NXlt5KV1aCSWRJ4Nub38OS1Zwg | 鍖垮悕 | txt | 楸� | NULL | 499a42935de84ca6b955d8737e289a75 |  | 1495528028 | false |
  For example:> "INSERT INTO wx_msg(id,openid,nickname,type,content,replyId,wxid,opBy,opAt,delFlag) VALUES('38292f4d8cc24ca2a76e9534029a5a89','o-NXlt5KV1aCSWRJ4Nub38OS1Zwg','鍖垮悕','txt','楸�','NULL','499a42935de84ca6b955d8737e289a75','',1495528028,false) "
[DEBUG] 2017-05-23 16:27:08,346 org.nutz.weixin.util.Wxs.asXml(Wxs.java:526) - Outcome >>
<xml>
<ToUserName><![CDATA[o-NXlt5KV1aCSWRJ4Nub38OS1Zwg]]></ToUserName>
<FromUserName><![CDATA[gh_8e20050bbc8d]]></FromUserName>
<CreateTime>1495528028</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[鎮ㄧ殑鐣欒█宸叉敹鍒帮紒]]></Content>
</xml>
4 回复

eclipse? idea?

多谢大神,就是第一条:打开IDEA安装目录找到 idea.exe.vmoptions(64位为idea64.exe.vmoptions)文件, 在文件末尾加上 -Dfile.encoding=UTF-8

学习新wk,也在学习新的ide。

添加回复
请先登陆
回到顶部