struts2.0中action:
public class ChunnelAction{@SuppressWarnings("unchecked")
public String add() {
      Chunnel c=new Chunnel();
//      c.setChunnelId(new Integer(10000));    //主键自动增加/
      c.setChunnelNum(getChunnel_num());
      c.setChunnelName(getChunnel_name());
      try{
    chunnelService.save(c);
    return "success";
      }catch(Exception e){
      e.printStackTrace();
      return "error";
      }   
    }
}
  Chunnel.java(VO) 
    public class Chunnel{    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)    //自动增长
    @Column(name="chunnel_id")
    public Integer getChunnelId() {
        return this.chunnelId;
    }
}
页面代码:
<s:form action="chunnel!add.action"><s:textfield id="num" name="chunnel_num" size="15" label="编号" />
<s:textfield id="name" name="chunnel_name" size="15" label="名称" /><s:submit value="新增" align="center" />
</s:form>  在数据库中,chunnel_id是主键,自动增长,
  在调用save(),控制台打出:信息: Detected AnnotationActionValidatorManager, initializing it...
  数据也没存进去,
  去掉自动增加,数据可以插进去,
    不知道哪出问题了?????????????

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【HQL_LIKE】截止到2008-07-18 15:27:35的历史汇总数据(不包括此帖):
    发帖的总数量:15                       发帖的总分数:280                      每贴平均分数:18                       
    回帖的总数量:9                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:10                       结贴的总分数:200                      
    无满意结贴数:2                        无满意结贴分:80                       
    未结的帖子数:5                        未结的总分数:80                       
    结贴的百分比:66.67 %               结分的百分比:71.43 %                  
    无满意结贴率:20.00 %               无满意结分率:40.00 %                  
    楼主加油
      

  2.   

    用 hibernate 了吗。。
    怎么配置的呢?
      

  3.   

    用JPA, 直接在VO里配置,@Id
        @GeneratedValue(strategy=GenerationType.AUTO)    //自动增长
        @Column(name="chunnel_id")
        public Integer getChunnelId() {
            return this.chunnelId;
        }

     数据插不进去