Variable declaration in Struts2

How to declare a variable and assign a value to this variable in Struts2?

+3
source share
3 answers

Use the set tag:

<s:set var="myVar">hello</s:set>

read var with:

<s:property value="#myVar"/>

Another example:

<s:set name="personName" value="person.name"/>
Hello, <s:property value="#personName"/>. How are you?

where the person is a bean in the value stack

+9
source

You do not need to declare variables in the JSP. Do this in your action and create a getter so that you can access it from the JSP showing the output of the action.

0
source

struts2 , Struts2 , (Variable) , .

all you need is to get getter and setter for your variable and you can access values ​​like (to / from) in struts2 using OGNL.OGNL is an expression language integrated with Struts2 that is able to abstract values ​​from the stack values ​​and will also perform data conversion (except for a custom type) for you

0
source

All Articles