Java中文问题集锦

王朝java/jsp·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

解决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:

解决办法:

第一:

1:在jsp页面加入:

<%@ page contentType="text/html; charset=gb2312" %

2:在servlet里面:

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType("text/html; charset=gb2312");//这是重要的

3:上面的如果在不行就用如下的方法在数据入库前进行调用:

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;

}

}

4.解决weblogic/webshpere中文问题:

在web.xml文件中需要配置中文环境。r如下:

<context-param

<param-nameweblogic.httpd.inputCharset./*</param-name

<param-valueGB2312</param-value

</context-param

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航