| Author |
Struts: No getter method for property name problem
|
Sujatha Kannan
Greenhorn
Joined: Dec 10, 2002
Posts: 8
|
|
Hi everyone, I am new to this struts. I have a samll application to check login. When I run my application I get this message in my server console No getter method for property user of bean org.apache.struts.taglib.html.BEAN I saw the previous forum for the same topic. I have checked my property names start with appropriate cases. Here is my code %@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html> <head><title>Login</title></head> <body> <html:form action="submit.do"> <table width="100%" border="0" height=75%> <tr> <td align="right" >UserName: </td> <td><html:text property="user"/></td> <tr> <tr> <td align="right" >Password: </td> <td><html:text property="password"/></td> </tr> <tr> <td colspan=2 align="center"><html:submit/></td> </tr> <tr> <td colspan=2 align="center"><html:errors/></td> </tr> </table> </html:form> </body> </html> import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; import java.util.*; /** * @author skannan * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ public class LoginForm extends ActionForm { private String user = null; private String password = null; /* user */ public String getUser() { return (this.user); } public void setUser(String user) { this.user = user; } /* password */ public String getPassword() { return (this.password); } public void setPassword(String password) { this.password = password; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // Log the forms data servlet.log("Lastname:" + user); servlet.log("Address:" + password); // Check for mandatory data ActionErrors errors = new ActionErrors(); if (user == null || user.equals("")) { errors.add("User", new ActionError("error.user")); } if (password == null || password.equals("")) { errors.add("Password", new ActionError("error.password")); } return errors; } } I am missing anything in my config files. Please I need help. Thanks!
|
 |
Sujatha Kannan
Greenhorn
Joined: Dec 10, 2002
Posts: 8
|
|
|
I found the problem and fixed it.
|
 |
Supraja Yasoda
Greenhorn
Joined: Mar 18, 2005
Posts: 5
|
|
Hai, I am having similar problem can u pls suggest me
|
 |
Stefan Willi
Ranch Hand
Joined: Mar 11, 2005
Posts: 47
|
|
Please, poste your action-mapping, your jsp(particularry the html:form) and your form bean. In my expirence, this message results mainly through a mismatch in the configuration. struts looks for the action-mapping, which is with the <html:form action="" /> definied. then it looks for the specified formbean and tries to match all your form-elements with a getter/setter of the form-bean. For example, if you have a spelling mismatch by a propertie, then you get this error. stefan
|
 |
 |
|
|
subject: Struts: No getter method for property name problem
|
|
|