2

我是新来的struts。我只是想构建一个简单的应用程序来获取用户的输入并显示它。为此,我从用户那里获得了输入并将其存储在一个 bean 中,并且我还使用 bean:write 在下一页中显示了它,但如何将它放在文本框中。我尝试使用 html:text 但我不知道如何将值放入其中。

提前致谢

4

4 回答 4

2

设置要在请求属性中显示的属性或 bean,并在最后一页中从中获取值:

在文本框中插入值的语法是

<html:text property="propertyName" value="value"></html:text/>
于 2009-03-13T04:19:23.367 回答
0

如果你想把它放在一个文本框中,我想你可能想试试 textfield 标签

于 2009-03-13T12:00:11.887 回答
0

您需要用 html:form 包装 html:text。html:form 的 action 属性将指向 struts-config.xml 中定义的动作。这个动作将与一个表单 bean 相关联,您在其中存储了您正在谈论的值。然后在 html:text 中像这样引用该属性

<html:text property="存储值的属性名"/>

于 2009-03-13T06:25:19.380 回答
0

您可以使用“”直接从bean中获取属性的值。前任:

<bean:write name="user" property="username" />
Replace by this:
<html:text name="user" property="username" style="width:150" maxlength="20"/>

In that:
name - is the bean object name
property - is the property of the bean object

祝你好运!

于 2009-07-17T08:24:20.007 回答