特急:在struts的使用中,怎么做到一个里的控件动态的升成

njxxs 2003-10-20 10:02:13
比如:
在一个form里面的控件<html:text property="name"> ,这个name文本框控件是根据数据库里面的name字段,根据数据库的记录数来确定控件数目,并要能够对数据进行处理。

不知道我说的各位大侠能否明白,救命的啊^-^
...全文
50 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ESoftWind 2003-10-23
  • 打赏
  • 举报
回复
Most of Struts Tag can be replaced with Struts EL(Expression Language, part of JSP1.2 specification) Tag, these tags help u to reduce "<%%>" code in jsp pages. such as:

<html-el:text property="${beanName}"/>

same as:

<html:text property="<%=beanName%>"/>

for more information, pls refer to jakarta web site
jiganghao 2003-10-23
  • 打赏
  • 举报
回复
nicholasdu()'s solution works for resolving nested struts tags, especially if the nest happens at multiple levels on different java beans. <bean:define> gives a intermidiate bean, like a java local variable.

with all the benifits, i still suggest use one bean in a jsp page, using nested representaion format (bean.propertyLevel1.propertyLevel2...). it is simpler and more concise.
jazzyboy 2003-10-21
  • 打赏
  • 举报
回复
“<html:text property="s_name" size="16" value="<bean:write name="element" property="s_name"/>"/>”
是什么东西?
写成:
<html:text name="element" property="s_name"/>


nicholasdu 2003-10-21
  • 打赏
  • 举报
回复
如果你要往value="..."加值的话可以这样处理
<bean:define id="name" type="java.lang.String" name="element" property="s_name"/>
<html:text property="s_name" size="16" value="<%=name%>"/>
一切ok了
whyxx 2003-10-21
  • 打赏
  • 举报
回复
<bean:define id="messlist" name="munumanageactionform" property="messlist" scope="request" />
<logic:iterate id="element" collection="<%=messlist%>" name="messlist" indexId="indexLine">
<tr>
<td width="6%"><div align="center">
<input type="checkbox" name="checkbox" value="checkbox">
</div></td>
<td width="15%"><div align="center">
<html:text name ="element" property="s_name" size="16" />
</div></td>
</tr>
</logic:iterate>

你试试看这样行不行,我觉得你的代码写得有问题
julian_zzx 2003-10-21
  • 打赏
  • 举报
回复
<input type="text" name="s_name" size="16" value="<bean:write name="element" property="s_name"/>">
一样吧,我试过了没什么区别,高人指教!~
julian_zzx 2003-10-21
  • 打赏
  • 举报
回复
试了一下,好像不行,
julian_zzx 2003-10-21
  • 打赏
  • 举报
回复
<input type="text" name="s_name" size="16" value='<bean:write name="element" property="s_name"/>'>
这么做可以,我就这么干的,

至于下面的
<html:text property="s_name" size="16" value='<bean:write name="element" property="s_name"/>'/>
我就没试过了
jiganghao 2003-10-21
  • 打赏
  • 举报
回复
p.s. for a form property with multiple values:

-- input (jsp to action): import BeanUtils package.
-- output (action to jsp): use <log:iterate> tag.
jiganghao 2003-10-21
  • 打赏
  • 举报
回复
I dont see much benefit of struts <html> tag. why not just use a normal html <input> tag? that you dont have embedded struts tags. the critial thing is to make your VO follow java bean protocol, so that you can use embedded bean structure representation.
CoolAbu 2003-10-20
  • 打赏
  • 举报
回复
你那样肯定不行,标签里面嵌套标签会报错的。我也碰到过这种问题,但是用<%%>解决的。
njxxs 2003-10-20
  • 打赏
  • 举报
回复
我想不使用<%%>代码,只用struts的libtag来做
请问怎么做才好呢
<logic:iterate id="element" name="munumanageactionform" property="messlist" type="org.xwtec.struts.sms_input.actionform.MenuManageActionForm">
<tr>
<td width="6%"><div align="center">
<input type="checkbox" name="checkbox" value="checkbox">
</div></td>
<td width="15%"><div align="center">

<html:text property="s_name" size="16" value="<bean:write name="element" property="s_name"/>"/>
</div></td>
</tr>
</logic:iterate>
可是报错,没有这个:<bean:write name="element" property="s_name"/>,一切正常,可是text就没的value了
JhonsonShu 2003-10-20
  • 打赏
  • 举报
回复
JSP:

loop:
rs.movenext
String strName = rs.getString(...);
<html:text property="<%=strName%>">
end loop
xmpp 2003-10-20
  • 打赏
  • 举报
回复
可能,但是你要做点其它的。<html:text>无非就是接受一些属性,输出一个文本框。你可以从定义一个标签,类似与<html:text>但是,他对body进行处理。但是,你在做这个标签之前,一点要搞懂struts中自带的util包中提供的API。
njxxs 2003-10-20
  • 打赏
  • 举报
回复
有哪个高手能够解决这样的标签里面嵌套标签的呢
帮帮忙撒
真的很急啊

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧