简体   繁体   中英

How to fill struts jsp text box out of string array data

JSP Code:

 <td><html:text   maxlength="52" name="MasterBean" property="names"  /> </td>
 <td><html:text   maxlength="52" name="MasterBean" property="names"  /> </td>
 <td><html:text   maxlength="52" name="MasterBean" property="names"  /> </td>
 <td><html:text   maxlength="52" name="MasterBean" property="names"  /> </td>

In Bean I have getter setter methods.

public String[] getNames() {
    return names;
}

public void setNames(String[] names) {
    this.names = names;
}

In the action class the bean gets populated correctly. But the values which are displayed in text boxes doesn't make any sens.

[Ljava.lang.String;@42a0b130
[Ljava.lang.String;@42a0b130
[Ljava.lang.String;@42a0b130
[Ljava.lang.String;@42a0b130

Persisting part is fine. But displaying what's being persisted is not working. Any Idea?

I'm Using Struts1

You should have a look at indexed properties . What you see is the string representation of your array (always the same object).
You need to do some indexing like this

<td><html:text   maxlength="52" name="MasterBean" property="names[index]"  /> </td>    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM