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...
数据也没存进去,
去掉自动增加,数据可以插进去,
不知道哪出问题了?????????????
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...
数据也没存进去,
去掉自动增加,数据可以插进去,
不知道哪出问题了?????????????
解决方案 »
- 参数传递问题----String 类型的变量不是对象吗?
- 关于Subversion 代理设置
- 【请教】WebSphere7.0中如何发布WAR格式应用?
- failed to lazily initialize a collection of role: no session or session was closed
- [调查]Taglib在真实项目中运用的广泛程度?
- 如何在tomcat中设置system property
- hibernate中有没有工具可以从现有的pojo反响生成到数据库的功能??
- 关于如何即准确又高效的显示错误!
- 问:EJB中的Bean、remote/local、home/localHome三者之间的关系?
- 晕了晕了又晕了:Java技术有多少分支:j2ee,j2me,serlet,javabean?平常说的学习Java,都是什么意思?
- JMS Template持久化问题
- IE小问题
楼主【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 %
楼主加油
怎么配置的呢?
@GeneratedValue(strategy=GenerationType.AUTO) //自动增长
@Column(name="chunnel_id")
public Integer getChunnelId() {
return this.chunnelId;
}
}
数据插不进去