我想使用 bean 设置属性<jsp:setProperty>
并使用param
. 这是代码:
在create.jsp 中:
<form id="form1" name="form1" action="save.jsp" method="POST"
enctype="multipart/form-data">
<input required="" type="text" name="nam">
在save.jsp 中:
<jsp:useBean class="jbeans.account.BankAccount" scope="request" id="ac1">
</jsp:useBean>
<jsp:setProperty name="ac1" property="accountHolderName" param = "nam">
</jsp:setProperty>
<%
ac1.createAccount(request); //createAccount is a public method.
//Recieving value of nam always as null
%>
在jbeans.account.BankAccount.java 中:
public void setAccountHolderName(String accountHolderName) {
this.accountHolderName = accountHolderName;
}
nam
当我在文本框中键入值时,accountHolderName
我收到的值始终是null
. 如何获得正确的价值?