解決java中文問題
針對applet和awt
Font f = new Font(UIResource
getString(
Default_font
)
Font
PLAIN
);
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);
Font f = new Font(
隸書
Font
PLAIN
);
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=gb
%>
:在servlet裡面:
public void doGet(HttpServletRequest request
HttpServletResponse response) throws ServletException
IOException {
response
setContentType(
text/html; charset=gb
);//這是重要的
:上面的如果在不行就用如下的方法在數據入庫前進行調用
public static String UnicodeToChinese(String s){
try{
if(s==null||s
equals(
)) return
;
String newstring=null;
newstring=new String(s
getBytes(
ISO
_
)
gb
);
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(
gb
)
ISO
_
);
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
解決weblogic/webshpere中文問題 在web
xml文件中需要配置中文環境
r如下
<context
param>
<param
name>weblogic
*</param
name>
<param
value>GB
</param
value>
</context
param>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19336.html