熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

Java 中文問題 集錦

2013-11-15 11:38:05  來源: JSP教程 

  解決java中文問題
  針對applet和awt
  
  Font f = new Font(UIResourcegetString( Default_font)FontPLAIN);
  UIManagerput(Labelfontf);
  UIManagerput(LabelforegroundColorblack);
  UIManagerput(Buttonfontf);
  UIManagerput(Menufontf);
  UIManagerput(MenuItemfontf);
  UIManagerput(Listfontf);
  UIManagerput(CheckBoxfontf);
  UIManagerput(RadioButtonfontf);
  UIManagerput(ComboBoxfontf);
  UIManagerput(TextAreafontf);
  
  
  Font f = new Font(隸書FontPLAIN);
  UIManagerput(Buttonfontfont);
  UIManagerput(ToggleButtonfontfont);
  UIManagerput(RadioButtonfontfont);
  UIManagerput(CheckBoxfontfont);
  UIManagerput(ColorChooserfontfont);
  UIManagerput(ToggleButtonfontfont);
  UIManagerput(ComboBoxfontfont);
  UIManagerput(ComboBoxItemfontfont);
  UIManagerput(InternalFrametitleFontfont);
  UIManagerput(Labelfontfont);
  UIManagerput(Listfontfont);
  UIManagerput(MenuBarfontfont);
  UIManagerput(Menufontfont);
  UIManagerput(MenuItemfontfont);
  UIManagerput(RadioButtonMenuItemfontfont);
  UIManagerput(CheckBoxMenuItemfontfont);
  UIManagerput(PopupMenufontfont);
  UIManagerput(OptionPanefontfont);
  UIManagerput(Panelfontfont);
  UIManagerput(ProgressBarfontfont);
  UIManagerput(ScrollPanefontfont);
  UIManagerput(Viewportfont);
  UIManagerput(TabbedPanefontfont);
  UIManagerput(TableHeaderfontfont);
  UIManagerput(TextFieldfontfont);
  UIManagerput(PasswordFiledfontfont);
  UIManagerput(TextAreafontfont);
  UIManagerput(TextPanefontfont);
  UIManagerput(EditorPanefontfont);
  UIManagerput(TitledBorderfontfont);
  UIManagerput(ToolBarfontfont);
  UIManagerput(ToolTipfontfont);
  UIManagerput(Treefontfont);
  
  針對jsp和servlet
  解決辦法
  第一
  :在jsp頁面加入
  <%@ page contentType=text/html; charset=gb %>
  :在servlet裡面:
  public void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
  responsesetContentType(text/html; charset=gb);//這是重要的
  
  :上面的如果在不行就用如下的方法在數據入庫前進行調用
  public static String UnicodeToChinese(String s){
  try{
  if(s==null||sequals()) return ;
  String newstring=null;
  newstring=new String(sgetBytes(ISO_)gb);
  return newstring;
  }
  catch(UnsupportedEncodingException e)
  {
  return s;
  }
  }
  
  public static String ChineseToUnicode(String s){
  try{
  if(s==null||sequals()) return ;
  String newstring=null;
  newstring=new String(sgetBytes(gb)ISO_);
  return newstring;
  }
  catch(UnsupportedEncodingException e)
  {
  return s;
  }
  }
  
  解決weblogic/webshpere中文問題
  在webxml文件中需要配置中文環境r如下
  <contextparam>
  <paramname>weblogic*</paramname>
  <paramvalue>GB</paramvalue>
  </contextparam>

From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19336.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.