如下所示的jsp
<body>
<html:form action="/saveSellCount1">
<nested:root name="sellCountForm">
<nested:nest property="sellcount"><%--0--%>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="327" height="218" id="AutoNumber1">
<nested:nest property="dealer"><%--1--%>
<tr>
<td width="111" height="71">经销商</td>
<td width="210" height="71"><nested:write property="dealerName"/></td>
<nested:hidden property="id"></nested:hidden>
</tr>
</nested:nest>
<tr>
<td width="111" height="77">标题</td>
<td width="210" height="77"><nested:text property="sellcountTitle"/> </td><%--2--%>
</tr> </table><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="500" height="218" id="AutoNumber1"> <tr>
<td>序号</td>
<td>油品</td>
<td>销量</td>
</tr>
<nested:iterate id="selldetail" indexId="i" property="TSellDetailSet" type="com.pojo.TSellDetail"><%--3--%>
<nested:root name="selldetail">
<tr>
<td><%=i%></td>
<nested:nest property="oil">
<td><nested:write property="oilName"/></td>
</nested:nest>
<td><nested:text property="sellCountprice"/></td><%--4--%>
</tr>
</nested:root>
</nested:iterate>
</table>
</center>
</div>
</nested:nest>
<html:submit>保存</html:submit>
</nested:root></html:form>
</body>
数据之间的关系是sellcount(标记<%--0--%>处)和dealer(标记<%--1--%>处)是多对一关系
sellcountTitle(标记<%--2--%>处)是sellcount的一个属性
selldetail (标记<%--3--%>处)和sellcount是多对一关系
sellCountprice(标记<%--4--%>处)是selldetail 的一个属性
///////////////////////////////////////////////////////////////////////////////////////////
产生这个页面之前的anction里面,有这样的一些hibernate语句,一些try/catch和sessionUtil语句我在这里没写,都是基础语句String id=request.getParameter("id");
TDealer dealer;
List oilListwo=null;
dealer=GetList.getDealer(id);//从id的到dealer对象
oilListwo=GetList.getOilListWithoutOther();//得到一个关于商品(油)的列表
TSellCount sellcount=new TSellCount();//new一个 sellcount对象
sellcount.setDealer(dealer);//建立sellcount和dealer的联系 TSellCountDAO dao=new TSellCountDAO();
Transaction tx=session.beginTransaction();
dao.save(sellcount,session);//我在这里save了一下,是希望能得到一个uuid ,但是没有commit
String sellcountid=sellcount.getId();
for(int i=0;i<oilListwo.size();i++)//根据列表的size确定要向TSellDetailSet里面加几条记录
{
TSellDetail selldetail=new TSellDetail();
TOil oil=(TOil)oilListwo.get(i);
selldetail.setOil(oil);
selldetail.setSell(sellcount);
sellcount.addToTSellDetailSet(selldetail);//循环向set里面加入selldetail对象
}
SellCountForm sellCountForm=new SellCountForm();
sellCountForm.setSellcount(sellcount);
request.setAttribute("sellCountForm",sellCountForm);//最后是以一个form的形式传到jsp
return mapping.findForward("success");运行之后,jsp显示正常,我需要在标记<%--2--%>处(只需填入一条)和标记<%--4--%>处
(根据商品列表的大小:3,此处显示了3个text。一一填入)填入我的数据,问题出现在我点击 “保存”之后,从form里得到的SellDetailSet
(sellCount.getTSellDetailSet().size())的size是0(按说应该是3)
(在form得reset函数中我加了一句sellcount.setTSellDetailSet(new HashSet(),
其中sellcount是该form得一个变量)不知应该如何得到希望的值???
另外说一个现象,本来点击 “保存”之后,连dealer对象也得不到,我在jsp上加了一个
<nested:hidden property="id"></nested:hidden>以后就可以得到了,
是什么道理???、
同时也请各位大侠指出其它不足
<body>
<html:form action="/saveSellCount1">
<nested:root name="sellCountForm">
<nested:nest property="sellcount"><%--0--%>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="327" height="218" id="AutoNumber1">
<nested:nest property="dealer"><%--1--%>
<tr>
<td width="111" height="71">经销商</td>
<td width="210" height="71"><nested:write property="dealerName"/></td>
<nested:hidden property="id"></nested:hidden>
</tr>
</nested:nest>
<tr>
<td width="111" height="77">标题</td>
<td width="210" height="77"><nested:text property="sellcountTitle"/> </td><%--2--%>
</tr> </table><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="500" height="218" id="AutoNumber1"> <tr>
<td>序号</td>
<td>油品</td>
<td>销量</td>
</tr>
<nested:iterate id="selldetail" indexId="i" property="TSellDetailSet" type="com.pojo.TSellDetail"><%--3--%>
<nested:root name="selldetail">
<tr>
<td><%=i%></td>
<nested:nest property="oil">
<td><nested:write property="oilName"/></td>
</nested:nest>
<td><nested:text property="sellCountprice"/></td><%--4--%>
</tr>
</nested:root>
</nested:iterate>
</table>
</center>
</div>
</nested:nest>
<html:submit>保存</html:submit>
</nested:root></html:form>
</body>
数据之间的关系是sellcount(标记<%--0--%>处)和dealer(标记<%--1--%>处)是多对一关系
sellcountTitle(标记<%--2--%>处)是sellcount的一个属性
selldetail (标记<%--3--%>处)和sellcount是多对一关系
sellCountprice(标记<%--4--%>处)是selldetail 的一个属性
///////////////////////////////////////////////////////////////////////////////////////////
产生这个页面之前的anction里面,有这样的一些hibernate语句,一些try/catch和sessionUtil语句我在这里没写,都是基础语句String id=request.getParameter("id");
TDealer dealer;
List oilListwo=null;
dealer=GetList.getDealer(id);//从id的到dealer对象
oilListwo=GetList.getOilListWithoutOther();//得到一个关于商品(油)的列表
TSellCount sellcount=new TSellCount();//new一个 sellcount对象
sellcount.setDealer(dealer);//建立sellcount和dealer的联系 TSellCountDAO dao=new TSellCountDAO();
Transaction tx=session.beginTransaction();
dao.save(sellcount,session);//我在这里save了一下,是希望能得到一个uuid ,但是没有commit
String sellcountid=sellcount.getId();
for(int i=0;i<oilListwo.size();i++)//根据列表的size确定要向TSellDetailSet里面加几条记录
{
TSellDetail selldetail=new TSellDetail();
TOil oil=(TOil)oilListwo.get(i);
selldetail.setOil(oil);
selldetail.setSell(sellcount);
sellcount.addToTSellDetailSet(selldetail);//循环向set里面加入selldetail对象
}
SellCountForm sellCountForm=new SellCountForm();
sellCountForm.setSellcount(sellcount);
request.setAttribute("sellCountForm",sellCountForm);//最后是以一个form的形式传到jsp
return mapping.findForward("success");运行之后,jsp显示正常,我需要在标记<%--2--%>处(只需填入一条)和标记<%--4--%>处
(根据商品列表的大小:3,此处显示了3个text。一一填入)填入我的数据,问题出现在我点击 “保存”之后,从form里得到的SellDetailSet
(sellCount.getTSellDetailSet().size())的size是0(按说应该是3)
(在form得reset函数中我加了一句sellcount.setTSellDetailSet(new HashSet(),
其中sellcount是该form得一个变量)不知应该如何得到希望的值???
另外说一个现象,本来点击 “保存”之后,连dealer对象也得不到,我在jsp上加了一个
<nested:hidden property="id"></nested:hidden>以后就可以得到了,
是什么道理???、
同时也请各位大侠指出其它不足
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货