I want to retrieve all the contents of the array in the session.

Asked 2 years ago, Updated 2 years ago, 125 views

Servlet side

public class data {
private String id;
private String name;

public data(String id, String name) {
this.id=id;
this.name = name;
} // constructor


ArrayList<Object>list=new ArrayList<>();
list.add(new data("1", "aiueo"));
list.add(new data("2", "kakikukeko"));
list.add(new data("3", "sasisuseo"));
session.put("data",data);
//jsp side
<s:property value="session.data"/>//Unable to retrieve.

<s:property value="session.data">
<s:property value="id"/>
<s:property value="name"/>
</s:property>// This also causes errors

<s:property>How do I retrieve it using the tag

jsp

2022-09-30 17:34

1 Answers

I would like to write it in EL expression.If so,

<s:property value="${session.data}"/>

Or simply skip session and

<s:property value="${data}"/>

How about

# This method will produce the same result as ArrayList.toString().
Therefore, you must override the class data method toString to string the value of the member variable.


2022-09-30 17:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.