添加到数据库(提交数据)后,没有在我的 AccessBean 中获取最新插入的数据。但是当我再次回到 jsp 时,数据是可用的。我不知道如何解决这个问题。
下面是 cmdImpl 中的插入代码
AddressAccessBean add = new AddressAccessBean(Long.parseLong(memberid),shipid);
shipBean.setInitKey_ShipToCodeName(shipid);
add.setAddressField2(shipBean.getName()+shipBean.getCity()+shipBean.getState());
add.setAddressField1("WD");
add.setMemberId(memberid);
add.setAddressField3(shipid);
add.setStatus("P");
add.commitCopyHelper();
提交数据后,尝试通过accessbeans及其finder方法在jsp上获取数据并显示到jsp中的表中
<%
String[] member_Id = (String[])request.getAttribute("memberid");
String memberId=member_Id[0];
AddressAccessBean add = new AddressAccessBean();
java.util.Enumeration enu = add.findByMemberId(Long.parseLong(memberId));
while (enu.hasMoreElements()) {
AddressAccessBean as = (AddressAccessBean) enu.nextElement();
if (as.getAddressField3() != null && as.getAddressField1().equals("WD")) {
com.ibm.commerce.extension.objects.xShipToCodeAccessBean bb = new com.ibm.commerce.extension.objects.xShipToCodeAccessBean().findByShipToCodeName(as.getAddressField3());
%>
<TR>
<Td ALIGN="LEFT" width="20%"><%=as.getAddressField2()%></Td>
<Td ALIGN="LEFT" width="20%"><%=bb.getName()%></Td>
<Td ALIGN="LEFT" size="15%"><%=bb.getShipToCodeName()%></Td>
<Td ALIGN="LEFT" size="10%"><%=bb.getCity()%></Td>
<Td ALIGN="LEFT" size="10%"><%=bb.getState()%></Td>
<Td ALIGN="LEFT" size="10%"><%=bb.getSoldTo()%>
</Td>