简体   繁体   中英

Convert list of java object in javascript arraylist

I have a question: I have a java object that's a List<User> and I want pass it to javascript for populate the source of a jQuery autocomplete. From jsp I pass the object present in the session by this tag

<input type="hidden" id="all_users" value=" < s: property value="#session.allUsers" /> " />

Then in javascript

var allUsers = $('#all_users').val().replace('[','').replace(']','').split(',');

Now I don't know what's next step because I obtain value as bean.User@4a255c. How I can convert this object for manage it in javascript and obtain the values that contains?

我没有Struts的经验,但您可以尝试以下方法:

<input type="hidden" id="all_users" value=" < s: property value="#Arrays.toString(session.allUsers.toArray())" /> " />

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