开发者

Struts 1: Accessing form values with bean:write

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 f开发者_高级运维orm on this jsp page?

Many thanks!


writing properties from a form with bean:write is possible with using the form name. in your case you can use the following code:

form: <bean:write name="TestForm"/>##
id = <bean:write name="TestForm" property="id" />

This should work better i guess

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜