解决java中文问题:
针对applet和awt:
1:)
Font f = new Font(UIResource.getString( "Default_font"),Font.PLAIN,12);
UIManager.put("Label.font",f);
UIManager.put("Label.foreground",Color.black);
UIManager.put("Button.font",f);
UIManager.put("Menu.font",f);
UIManager.put("MenuItem.font",f);
UIManager.put("List.font",f);
UIManager.put("CheckBox.font",f);
UIManager.put("RadioButton.font",f);
UIManager.put("ComboBox.font",f);
UIManager.put("TextArea.font",f);
2:)
Font f = new Font("隶书",Font.PLAIN,15);
UIManager.put("Button.font",font);
UIManager.put("ToggleButton.font",font);
UIManager.put("RadioButton.font",font);
UIManager.put("CheckBox.font",font);
UIManager.put("ColorChooser.font",font);
UIManager.put("ToggleButton.font",font);
UIManager.put("ComboBox.font",font);
UIManager.put("ComboBoxItem.font",font);
UIManager.put("InternalFrame.titleFont",font);
UIManager.put("Label.font",font);
UIManager.put("List.font",font);
UIManager.put("MenuBar.font",font);
UIManager.put("Menu.font",font);
UIManager.put("MenuItem.font",font);
UIManager.put("RadioButtonMenuItem.font",font);
UIManager.put("CheckBoxMenuItem.font",font);
UIManager.put("PopupMenu.font",font);
UIManager.put("OptionPane.font",font);
UIManager.put("Panel.font",font);
UIManager.put("ProgressBar.font",font);
UIManager.put("ScrollPane.font",font);
UIManager.put("Viewport",font);
UIManager.put("TabbedPane.font",font);
UIManager.put("TableHeader.font",font);
UIManager.put("TextField.font",font);
UIManager.put("PasswordFiled.font",font);
UIManager.put("TextArea.font",font);
UIManager.put("TextPane.font",font);
UIManager.put("EditorPane.font",font);
UIManager.put("TitledBorder.font",font);
UIManager.put("ToolBar.font",font);
UIManager.put("ToolTip.font",font);
UIManager.put("Tree.font",font);
3:)针对jsp和servlet:
解决办法:
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
3:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GB2312</param-value>
</context-param>
分享到:
相关推荐
由于Java编程中的中文问题是一个老生常谈的问题,在阅读了许多关于Java中文问题解决方法之后,结合作者的编程实践,我发现过去谈的许多方法都不能清晰地说明问题及解决问题,尤其是跨平台时的中文问题。于是我给出此...
java解决中文乱码问题
java中文问题解决大全.doc 主要是对java开发当中遇到的所有中文乱码问题的解决。
解决JAVA编程中遇到的各种乱码问题,对乱码问题的分析
彻底解决JAVA读取写入 TXT中文乱码问题 源码
java中文乱码解决问题
Java关于中文乱码问题的多种解决方法,中文乱码过滤器
java解决解决get中文乱码问题,在项目中多次使用,从未有错!
JAVA解决URL路径中含有中文的问题。无论是路径中还是文件名包含中文都可以处理。经测试验证通过。
常见的java中文问题的解决方法
主要为大家分享了介绍了java中文乱码之解决URL中文乱码问题的方法,感兴趣的小伙伴们可以参考一下
NULL 博文链接:https://snailzhang-126-com.iteye.com/blog/512442
开发中前台页面向后台传参,汉字乱码,看了好多网上的方法都解决不了,所以写了一个工具类,判断是乱码就转换,不乱码就不乱换,汉字字母符号自动判断。最后完美解决汉字乱码问题。
JAVA常见中文乱码问题解决方法,JAVA常见中文乱码问题解决方法.
书里详细介绍了JAVA问题的产生.以及解决办法. 书为PDF格式
阅读许多关于中文乱码的解决办法的博文后,发现对于该问题我们都(更加包括我自己)没有一个清晰明了的认识,于是LZ想通过这系列博文(估计只有几篇)来彻底分析、解决java中文乱码问题,如有错误之处望各位同仁指出...
Java中文问题及解决方法 内容: 1.中文问题的来源 2.Java编码转换的过程 3.分析常见的Java中文问题 4.等
NULL 博文链接:https://362217990.iteye.com/blog/2294877