How to fetch <s:property value="userPojo.registerno"/>
into text field?
Code is here:
<%@taglib uri="/struts-tags" prefix="s"%>
<body bgcolor='cyan'>
<center>
<font color='green' size="5pxl"><u><b>User Edit form</b></u></font><br>
<s:form action="newuser">
<table border="0" background="red" cellpadding="5">
<tr><td>
<s:textfield name="regnumber" label="Registration Number"
id="regnumber" value="<s:property value='userPojo.regnumber'/>"/>
</td></tr>
</table>
</s:form>
</center>
</body>
In the struts tags you don't need to and you can't use s:property
tag to write a value into the value
attribute. You can get a value via OGNL expression. Also note, the value attribute is used to define a default value for the field that overrides the value used by the name
attribute. Your name attribute differs from value attribute, so you should have both properties defined with getters and setters. The name
attribute is used to set a value from textfield when you submit the form.
<s:textfield name="regnumber" label="Registration Number" id="regnumber" value="%{userPojo.regnumber}"/>