When I run a very simple
struts application I get the following error message:
[ServletException in:/pages/Name.jsp] No getter method for property firstName of bean org.apache.struts.taglib.html.BEAN'
The property fields in the beans have the correct case.
Bean:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import java.util.*;
public class NameActionForm extends ActionForm {
private
String firstName = "";
private String lastName = "";
private String initial = "";
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getInitial() {
return initial;
}
public void setFirstName(String name) {
firstName = name;
}
public void setLastName(String name) {
lastName = name;
}
public void setInitial(String init) {
initial = init;
}
}
struts-config (parts of it)
<form-beans>
<form-bean
name="addresses"
type="AddressActionForm"/>
<form-bean
name="names"
type="NameActionForm"/>
</form-beans>
<global-forwards>
<forward
name="name"
path="/Name.do" />
</global-forwards>
jsp page (Name.jsp)
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html:form action="/Addresses">
<table>
<tr>
<th>
First Name:
</th>
<th>
Last Name:
</th>
<th>
Initial
</th>
</tr>
<tr>
<td>
<html:text property="firstName" size="20"/>
</td>
<td>
<html:text property="lastName" size="30"/>
</td>
<td>
<html:text property="initial" size="1"/>
</td>
</tr>
</table>
<html:submit
property="submit">Submit</html:submit>
</html:submit>
If I change the line
<html:form action="/Addresses"> to
<html:form name="names" type="NameActionForm" action="/Addresses">
It works fine. Any help would be appreciated.
</html:form>