只需在JavaBean中的getXxx方法中进行修改
public class Login { private String userName; //用户名 private String password; //密码 public Login(){ //构造方法 } public String getUserName() { //返回用户名 try{ //通过getBytes("ISO-8859-1")方法把字符转换为标准字符 byte b[]=userName.getBytes("ISO-8859-1"); //把字符转化为UTF-8编码 userName=new String(b,"UTF-8"); return userName; }catch(Exception e){ return userName; } } public void setUserName(String userName) { //设置用户名 this.userName = userName; } public String getPassword() { try{ byte b[]=password.getBytes("ISO-8859-1"); password=new String(b,"UTF-8"); return password; }catch(Exception e){ return password; } } public void setPassword(String password) { this.password = password; } }