struts中的Action在编辑时,如何将值附给jsp页面的<html:text ....> 将Action对应的ActionForm的userName属性赋值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在action中用request.setAttribute("key",object);在页面中<input type="text" name="name" value="<bean:write name="key" property="userName" />"> 不想用value这样附值,还有什么更好的方法吗? flyxxxxx(灭神) ,你的方法是?最好是能直接在Action里面更改userName的属性并附值~ ActionForm里面定义页面相同变量名, 在ActionForm中赋值,jsp中使用标签<bean:write name = "(你的ActionForm名称)" property = "(你的变量名)"/>就可以了 flyxxxxx(灭神)说的对我再具体说一下你的action可以这样写(其中的一部分哦)UserForm userForm = new UserForm();userForm.setUserName("weki");request.setAttribute("userForm",userForm);action完毕在jsp中<logic:iterate id="q" name="userForm" > <bean:write name="q" property="userName"/></logic:iterate>或者直接<bean:write name="userForm" property="userName"/>这只是个思路。具体的我有点忘记了也可能你直接拿过去不会成功稍作调试问题不大。 <logic:iterate> 这个循环标签,写这个做什么? to: paopao270(泡泡(java追求者j2ee)) 我是想实现编辑时显示值在input里面操作一个 <bean:write name="q" property="userName"/> 显然是错误的。 你需要在ActionForm中这样处理: private String clname;//值对象中的一个属性 private AirLine airLine;//VO值对象 public String getClname() { return this.airLine.getClname(); } public void setClname(String clname) { this.airLine.setClname(clname); } public String getCsname() { return this.airLine.getCsname(); }public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { HttpSession session = httpServletRequest.getSession(); this.airLine = (AirLine)session.getAttribute("airLine"); }在页面中直接写成<html:text property="userName">就可得到值 大神们 帮看看这个是啥意思 求个java抓取ajax动态网页的方法 openldap+LdapBrowser配置连接问题 Mondrian Exception ibatis的问题 Hibernate原理问题? 大侠们帮忙看看这个递归程序出了什么问题? 请教APPLET和EJB的问题 java IDL和RMI-IIOP有什么区别? 漂亮妹妹请教 如何在jboss中运行jsp 一个小错误不知道在哪里有问题?
在页面中<input type="text" name="name" value="<bean:write name="key" property="userName" />">
我再具体说一下
你的action可以这样写(其中的一部分哦)
UserForm userForm = new UserForm();
userForm.setUserName("weki");
request.setAttribute("userForm",userForm);
action完毕
在jsp中
<logic:iterate id="q" name="userForm" >
<bean:write name="q" property="userName"/>
</logic:iterate>
或者直接
<bean:write name="userForm" property="userName"/>
这只是个思路。具体的我有点忘记了
也可能你直接拿过去不会成功
稍作调试问题不大。
我是想实现编辑时显示值在input里面操作一个 <bean:write name="q" property="userName"/> 显然是错误的。
private String clname;//值对象中的一个属性
private AirLine airLine;//VO值对象
public String getClname() {
return this.airLine.getClname();
}
public void setClname(String clname) {
this.airLine.setClname(clname);
}
public String getCsname() {
return this.airLine.getCsname();
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
this.airLine = (AirLine)session.getAttribute("airLine");
}在页面中直接写成<html:text property="userName">就可得到值