如何从struts bean中获取价值?
我是struts新手。 我只是想构建一个简单的应用程序来获取用户的输入并显示它。 为此,我从用户那里获取了输入并将其存储在一个 bean 中,并且我还使用 bean:write 在下一页中显示了它,但如何将其放置在文本框中。 我尝试使用 html:text 但我不知道如何将值放入其中。
提前致谢
I am new to struts. I'm just trying to build a simple application that gets the input from the user and display it. For which I got the input from the user and stored it in a bean and I have also displayed it in the next page using bean:write but how to place it in a text box. I tried to use html:text but I don't know how to place the value in it.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
设置要在请求属性中显示的属性或 bean,并在最终页面中从中获取值:
在文本框中插入值的语法是
Set the property or bean that you want to display in the request attribute and fetch the value from it in the final page:
The syntax for inserting a value in text box is
您需要用 html:form 包装 html:text。 html:form 的action 属性将指向struts-config.xml 中定义的action。 此操作将与一个表单 bean 相关联,您在其中存储了所讨论的值。 然后在 html:text 中引用该属性,如下所示
You need to wrap html:text with html:form. The action attribute of html:form will point to an action defined in struts-config.xml. This action will be associated with a form bean where you have stored the value you are talking about. Then in html:text refer to that property like this
<html:text property="property name where the value is stored"/>
如果您想将其放在文本框中,我想您可能想尝试 textfield标签
If you want to place that in a text box I think you might want to try textfield tag
您可以使用“”直接从bean中获取属性的值。
例如:
祝你好运!
You can use "" to directly get the value of the property from the bean.
Ex:
Good luck!