jsp:useBean-property and param

<%@ page contentType="text/html;charset=gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- 
在javaBean 中param="numItems"相当于 value="<%=request.getParameter("itemID")%>"//接收上一个页面传来的参数;
-->
<HTML>
<HEAD>
<TITLE>Using jsp:setProperty</TITLE>
</HEAD>
<BODY>
<TABLE BORDER=2 ALIGN="CENTER">
<TR>
<TH>Using jsp:setProperty
</TABLE>

<jsp:useBean id="entry" class="bean.SaleEntry" />

<jsp:setProperty name="entry" property="itemID" param="numItems" />
param="numItems"//相当于:value=<%=request.getParameter("numItems")%>接收上一个页面传来的参数值;

property="itemID"//会自动调用entry.setItemId(value);

<TABLE ALIGN="CENTER" BORDER=1>
<TR>
<TH>Item ID
<TR ALIGN="RIGHT">
<TD>

<jsp:getProperty name="entry" property="itemID" />
property="itemID"<!--//对象(SalEntry)entry会自动调用getItemId()方法,只要符合命名规范;-->

</TABLE>
</BODY>
</HTML>

你可能感兴趣的:(jsp:useBean-property and param)