0
將數據添加到數據庫(提交數據)後,沒有在我的AccessBean中獲取最新插入的數據。但是當我再次回到jsp時,數據可用。我不知道如何解決這個問題。如何通過jsp中的accessbean從數據庫中獲取數據
下面是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();
插入代碼commiting的data.trying通過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>