Struts 1:使用 bean:write 访问表单值
您好,
我认为这是一个简单的问题,但它现在仍然困扰着我。
我有一个 TestForm 类,其中包含常用的 getters/setters...例如,我有一个带有“getId”和“setId”方法的“id”字段。
在将表单发送到具有以下代码的 jsp 页面之前,我的表单已正确填充在操作类中(我通过单步调试 Eclipse 调试器了解到这一点):
<html:form action="/AppropriateAction">
<bean:define id="testFormA" name="TestForm" type="com.whatever.form.TestForm" />
form = <bean:write name="testFormA" />##
id = <bean:write name="testFormA" property="id" />##
</html:form>
我的输出如下所示:
form = com.whatever.form.TestForm13a3x4 ##
id = ##
现在我知道由于输出的第一行,页面可以正确地看到表单,但如果是这种情况,那么为什么 id 从这个语句中显示为空:
id = <bean:write name="testFormA" property="id" />##
我在做什么在这个jsp页面上访问我的表单的id字段是错误的?
非常感谢!
Greetings,
This is a simple question I believe, but nonetheless it is stumping me right now.
I have a TestForm class with your usual getters/setters...for example I have an "id" field with "getId" and "setId" methods.
My form is populated in an action class correctly (which I know from stepping through the Eclipse debugger) just before it is sent to the jsp page which has the code below:
<html:form action="/AppropriateAction">
<bean:define id="testFormA" name="TestForm" type="com.whatever.form.TestForm" />
form = <bean:write name="testFormA" />##
id = <bean:write name="testFormA" property="id" />##
</html:form>
My output looks like this:
form = com.whatever.form.TestForm13a3x4##
id = ##
Now I know that the page can see the form correctly due to the first line of the output, but if this is the case then why does the id show that it is empty from this statement:
id = <bean:write name="testFormA" property="id" />##
What am I doing wrong to access the id field of my form on this jsp page?
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 bean:write 从表单写入属性可以使用表单名称。在你的情况下,你可以使用以下代码:
我想这应该更好
writing properties from a form with bean:write is possible with using the form name. in your case you can use the following code:
This should work better i guess