centos java tomcat 中文乱码解决办法

现象: cenos 部署java web 程序 ,java类中有中文 出现乱码现象

 

即使使用:    

System.getProperty("中文")

 

控制台都出现  ??????  乱码,现象很奇怪

 

经查:

运行: 此方法 输出中发现有  

 

System.out.println(System.getProperty("file.encoding"));

 

ANSI_X3.4-1968

 

解决办法:

 

修改tomcat/bin  下的 catalina.sh 文件   ,在此文件中加入:

 

CATALINA_OPTS=-Dfile.encoding="UTF-8"    问题就解决了。

 

Java利用System.getProperty("file.encoding")获取编码分析

https://blog.csdn.net/loongshawn/article/details/50918506

 

java查询当前操作系统的默认编码方式

 

System.out.println(System.getProperty("sun.jnu.encoding"));;

posted @ 2018-07-13 20:25  糖豆爸爸  阅读(482)  评论(0编辑  收藏  举报
Live2D