Soham
Soham

Reputation: 91

Accessing the value of the variable defined locally in the method in action class in jsp using Struts2

I am trying to access the value of the variable defined in the method in the action class in jsp using Struts2. I have a variable defined desc_map in the method of the action class.I want to access the value of this in jsp. How can I do it? Thank you.

Upvotes: 0

Views: 1249

Answers (1)

Dave Newton
Dave Newton

Reputation: 160191

Create a public getter for the property, preferably named correctly as per the JavaBean spec:

public TheType getDescMap() {
    return desc_map;
}

Access it from the JSP:

${descMap}

Or if you need escaping, can't use JSP 2.0+, etc:

<s:property value="descMap"/>

All of this is covered in essentially every Struts 2 tutorial.

Upvotes: 2

Related Questions