数据库里面字段是byte类型的,不知道为什么要这个类型,不就是个boolean类型的判断
public class User{
private Integer id;
private Byte isAdmin;
//getter setter;
}悲剧的是,往action 里面的user赋值不成功,jsp页面端的user.isAdmin的值是0或者1,怎么办?
public class UserAction{
private User user;
public String addUser(){
service.save(user);
return "success";
}
}

解决方案 »

  1.   

    action定义为int,存的时候再变为byte

    乱说的,没这么用过byte感觉字段设为byte都是c/c++程序员比较喜欢做的事。
      

  2.   

    不知道啊,boolean 对应的sql server数据库的字段是bit(1)?????
    这个是以前的项目不能改字段的,是struts1.x的,记得没错的话它是这样的user.setIsAdmin(new Integer(form.getIsAdmin).byteValue());
    service.save(user);
      

  3.   

    action定义为int,存的时候再变为byte(我晕啊,action里面的user的很多字段都是byte的类型,意味要写N多转换的代码)
      

  4.   

    sql server中bit用true/false一样可以插入.!
    LZ,那个属性就用boolean
      

  5.   

    个人觉得Byte是byte基本类型的封装类,它比byte有更好的一些特性。