JSP文件中添加行的TEXTBOX改成
<input type='text' name="'list[" + i + "]." + arr[i] + "' size='10'/>
-----------------------------------------------------------------------Action中:
if(wagee.getAction().equals("addWage"))
{try{
wageeService.saveWagee(wagee,list);}catch(Exception e){
e.printStackTrace();
}
return mapping.findForward("addWage");
}
-----------------------------------------------------------------------
service:
private List<WageeFormBean> list= new ArrayList<WageeFormBean> ();
public List<WageeFormBean> getList() {
return this.list;
}
public void setList(List<WageeFormBean> list) {
this.list = list;
}public void saveWagee(WageeFormBean wagee, List<WageeFormBean> list){
try{
//把从页面中传过来的list中的空值去掉Wage co=new Wage();
BeanUtils.copyProperties(co,wagee);
wageDAO.saveWage(co);
for(int i=0;i<list.size();i++)
{
Wagee wa=new Wagee();
BeanUtils.copyProperties(wa,list.get(i));
wageeDAO.saveWagee(wa);
WageRelation re=new WageRelation();re.setWagee(wa);
re.setWage(co);
wageRelationDAO.saveWageRelation(re);
}
}catch(Exception e){
e.printStackTrace();
}
}
-----------------------------------------------------------------------
Hibernate: public void saveWagee(Wagee wa){
this.getHibernateTemplate().save(wa);
}-----------------------------------------------------------------------
其中 Wage是表头 Wagee是需要数据 WageeRelation中定义关联表 添加是只有表头添加到数据库 其他数据都添加不了,不知道为什么 tomcat服务器又没报错 好像是读取过来的Wagee中的数据是空的。
非常感谢啊
<input type='text' name="'list[" + i + "]." + arr[i] + "' size='10'/>
-----------------------------------------------------------------------Action中:
if(wagee.getAction().equals("addWage"))
{try{
wageeService.saveWagee(wagee,list);}catch(Exception e){
e.printStackTrace();
}
return mapping.findForward("addWage");
}
-----------------------------------------------------------------------
service:
private List<WageeFormBean> list= new ArrayList<WageeFormBean> ();
public List<WageeFormBean> getList() {
return this.list;
}
public void setList(List<WageeFormBean> list) {
this.list = list;
}public void saveWagee(WageeFormBean wagee, List<WageeFormBean> list){
try{
//把从页面中传过来的list中的空值去掉Wage co=new Wage();
BeanUtils.copyProperties(co,wagee);
wageDAO.saveWage(co);
for(int i=0;i<list.size();i++)
{
Wagee wa=new Wagee();
BeanUtils.copyProperties(wa,list.get(i));
wageeDAO.saveWagee(wa);
WageRelation re=new WageRelation();re.setWagee(wa);
re.setWage(co);
wageRelationDAO.saveWageRelation(re);
}
}catch(Exception e){
e.printStackTrace();
}
}
-----------------------------------------------------------------------
Hibernate: public void saveWagee(Wagee wa){
this.getHibernateTemplate().save(wa);
}-----------------------------------------------------------------------
其中 Wage是表头 Wagee是需要数据 WageeRelation中定义关联表 添加是只有表头添加到数据库 其他数据都添加不了,不知道为什么 tomcat服务器又没报错 好像是读取过来的Wagee中的数据是空的。
非常感谢啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货