<set>
Set new variable
Set new variable to variable value in context or session, you can use the Ognl expression to get the properties and methods of variable value in context or session.
var(required) Set new variable
setScope(optional) Set the scope of the variable Property context:Set variable to context(default) session:Set variable to session
value(required) Get variable value, can also get the Ognl values of the variable Optional value "str":String {"e1","e2","e3"}:List #{"key1":"value1","key2":"value2"}:Map
valueScope(optional) The scope of the variable Property context:Get variable from context(default) session:Get variable from session
Set new variable in var, the value get from context or session.
Process equivalent to:
Object value = context.getVariable(key)
Object value = context.getSessionVariable(key)
Then the set new variable stores the values:
context.setVariable(newKey, value)
context.setSessionVariable(newKey, value)
Example: In template or action, set 2 variables, id and name
Set new variable id_1 and name_1 to store the id and name, and use get tag to output id_1 and name_1.
Result
You can also set to session and get through scope from session
Result
As long as the value that conforms to Ognl can be set to new variable.
1.String 2.Numbers, Ognl can convert to Java type 3.List:{"e1","e2","e3"} 4.Map:#{"key1":"value1","key2":"value2"} 5.Ognl expression, for example 1 == 1, the value is true All of the "" can be replaced by ''
Example: 1.String: The value of a and B are str, if outside is '', inside is "", if inside is "", outside is ''. 2.Numbers: c's value is 1, Ognl convert to Integer; d's value is 1.1, Ognl convert to Double. 3.List: Writing is {"e1","e2","e3"}. 4.Map: Writing is #{"key1":"value1","key2":"value2"}. 5.Ognl expression: 1 == 1 the value is Boolean type.
Use get tag to get them
Result
Set new variable value can also get the chain field or method
The above example
new variable e, get string uppercase; new variable f, The result of a multiplication formula; new variable g, get the list size; new variable h, get the value of the Map key key2.
Result