I have a JSP and I want to fill some fields with information from my Action class.
In my Action class I have a PersonDTO object.
It’s some example code only to get a picture of the design
int id = 4;
Person result = findMyRowFromDb(id);
PersonDTO personDTO = new PersonDTO(result);
return "fillForm"
So in my JSP I want to get the values from my object.
I write something like
<input type="text" name="PersonName" id="PersonName"
value='<s:property value="personDTO.name"/>'/>
name is a field of my PersonDTO object.
But nothing is displayed.
Can anyone help me?
Yes as doctrey mentioned, to display the
<s:property value="personDTO.name"/>value,personDTOhave to be an instance variable of your action class and also inPersonDTOclass there should be a getter method for thenameattribute. If so you will see your result.And also you don’t have to use
<s:property>here, you can use<s:textfield>tag like following,