今天下午在调程序时,发现老是乱码,由于前阵子一直在甘肃出差,回来后系统重装,所以猜测可能是设置的问题。
于是
1、修改了系统里的字符集设置,MyEclipse --> window --> Preferences --> General --> Content Types --> Test --> 单击 Java Properties File, 改成utf-8,然后update. 保存。
2、使用MyEclipse下自带的JDK/bin目录下的native2ascii对属性进行处理:
natvie2ascii -encoding utf-8 源文件 目的文件。
经过上述操作后,重新部署,发现还是??
3、于是又在stucts里写了一个控制Action:
protected void processLocale( HttpServletRequest request, HttpServletResponse response )
{
super.processLocale( request, response );
try
{
request.setCharacterEncoding( "utf-8" );
}
catch( Exception ex )
{
}
}
最后终于显示成中文。