懂struts的人进来看看 应该是bean,比如在action中request.setAttribute("result",result); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 id 是哪个bean,name是你的formbean 的名字,你弄混了, <logic:iterate id="user" name="userForm" property="XXXXXX">你得加上property属性才行,这样iterate才知道把你form里什么东西拿来做循环,比如arraylist什么的. <logic:iterate id="user" name="userForm" ><bean:write name="user" property="UserID" />这两个name指的是同一个bean吧对于property属性,不知道加什么了,我加了一个数据库里面的字段,提示说:No getter method for property users of bean userForm 我的UserForm是这样的:我的property属性该怎么写?!package com.sunw.Form;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionError;public class UserForm extends ActionForm { protected int UserID; protected String UserName; protected String UserSex; protected String UserEmail; public void setUserID(int UserID) { this.UserID = UserID; } public int getUserID() { return UserID; } public void setUserName(String UserName) { this.UserName = UserName; } public String getUserName() { return UserName; } public void setUserSex(String UserSex) { this.UserSex = UserSex; } public String getUserSex() { return this.UserSex; } public void setUserEmail(String UserEmail) { this.UserEmail = UserEmail; } public String getUserEmail() { return UserEmail; } // This method is called with every request. It resets the Form // attribute prior to setting the values in the new request. public void reset(ActionMapping mapping, HttpServletRequest request) { this.UserID = 0; this.UserName = ""; this.UserSex = ""; this.UserEmail = ""; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ( (UserName == null) || (UserName.length() == 0) ) { errors.add("UserName", new ActionError("errors.UserName.required")); } if ( (UserSex == null) || (UserSex.length() == 0) ) { errors.add("UserSex", new ActionError("errors.UserSex.required")); } if ( (UserEmail == null) || (UserEmail.length() == 0) ) { errors.add("UserEmail", new ActionError("errors.UserEmail.required")); } return errors; }} 楼主这个问题简单我也遇到过logic:iterate标签中你的name用错了不应该是actionForm,而应该是request.setAttribute("aaa",list);大概你的意思是要显示所有数据所以你这个list要用数组表示,aaa放到你的logic标签中<logic:iterate id="a" name="aaa">就可以了这个id可以自己随便写,但是下面的bean:write中的name就是这个id,例如:<bean:write name="a" property=""/> 你的form里面哪有collectoin来做iterate啊,只有一些String嘛 其实楼上说的form中要collection来着iterate没有必要的注意:id="findalltrainhead"这个id自己可以随便定义,要和<bean:write name="findalltrainhead" property="deptName"/>中的name一致。 <logic:iterate id="findalltrainhead" name="findalltrainheadresult" > <tr> <td nowrap bgcolor="#CCCCCC"> </td> <td height="31" nowrap bgcolor="#CCCCCC"> </td> <td bgcolor="#CCCCCC"> <bean:write name="findalltrainhead" property="deptName"/> </td> <td bgcolor="#CCCCCC"> <bean:write name="findalltrainhead" property="headerTypeName"/> </td> <td height="31" bgcolor="#CCCCCC"> <bean:write name="findalltrainhead" property="telNum"/> </td> </tr> </logic:iterate>再Action中的execute方法中你要这样写request.setAttribute("findalltrainheadresult",arrayList);如果有什么问题随时探讨 你应该在Form中定一个数组或HashMap之类的集合。然后再用iterate,iterate 是需要一个collction的数据结构的。你单独指定form就会出错。 坚决同意 qjhaaaaa 的观点! jquery JAVA自动发动邮件... 请大家帮忙优化一个SQL 关于AJAX的Bean注入 加减乘除 jsp写出文件 各位高手帮忙找下原因,急啊!!! 求助:spring中使用Hibernate做多对多,查询时会删除关系表的数据,极度郁闷中.... 菜鸟提问web services,大家请帮帮忙哦!!! java时间问题 java.util.ArrayList中值对象排序问题. 大家推荐几本学习J2EE的好书。
你得加上property属性才行,这样iterate才知道把你form里什么东西拿来做循环,比如arraylist什么的.
<bean:write name="user" property="UserID" />
这两个name指的是同一个bean吧
对于property属性,不知道加什么了,我加了一个数据库里面的字段,提示说:No getter method for property users of bean userForm
package com.sunw.Form;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;public class UserForm extends ActionForm { protected int UserID;
protected String UserName;
protected String UserSex;
protected String UserEmail; public void setUserID(int UserID) {
this.UserID = UserID;
}
public int getUserID() {
return UserID;
}
public void setUserName(String UserName) {
this.UserName = UserName;
}
public String getUserName() {
return UserName;
} public void setUserSex(String UserSex) {
this.UserSex = UserSex;
}
public String getUserSex() {
return this.UserSex;
} public void setUserEmail(String UserEmail) {
this.UserEmail = UserEmail;
}
public String getUserEmail() {
return UserEmail;
}
// This method is called with every request. It resets the Form
// attribute prior to setting the values in the new request.
public void reset(ActionMapping mapping, HttpServletRequest request) { this.UserID = 0;
this.UserName = "";
this.UserSex = "";
this.UserEmail = "";
} public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) { ActionErrors errors = new ActionErrors();
if ( (UserName == null) || (UserName.length() == 0) ) { errors.add("UserName", new ActionError("errors.UserName.required"));
}
if ( (UserSex == null) || (UserSex.length() == 0) ) { errors.add("UserSex", new ActionError("errors.UserSex.required"));
}
if ( (UserEmail == null) || (UserEmail.length() == 0) ) { errors.add("UserEmail", new ActionError("errors.UserEmail.required"));
}
return errors;
}
}
我也遇到过
logic:iterate标签中你的name用错了
不应该是actionForm,而应该是
request.setAttribute("aaa",list);
大概你的意思是要显示所有数据
所以你这个list要用数组表示,aaa放到你的logic标签中
<logic:iterate id="a" name="aaa">
就可以了
这个id可以自己随便写,
但是下面的
bean:write中的name就是这个id,
例如:<bean:write name="a" property=""/>
没有必要的
注意:id="findalltrainhead"这个id自己可以随便定义,要和<bean:write name="findalltrainhead" property="deptName"/>中的name一致。
<logic:iterate id="findalltrainhead" name="findalltrainheadresult" >
<tr>
<td nowrap bgcolor="#CCCCCC">
</td>
<td height="31" nowrap bgcolor="#CCCCCC">
</td>
<td bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="deptName"/>
</td>
<td bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="headerTypeName"/>
</td>
<td height="31" bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="telNum"/>
</td>
</tr>
</logic:iterate>再Action中的execute方法中
你要这样写
request.setAttribute("findalltrainheadresult",arrayList);如果有什么问题
随时探讨
你单独指定form就会出错。