Struts 2 assigning property tag value to hidden field

I want to assign a value from the Description field to a hidden field test. But the problem is that "Description" contains a sequence of words and the following code only assigns the first word "test"

<s:hidden value=<s:property value="Description" /> name="test">

I'm kind of new to layout. Can someone help. Also it would be nice if I get familiar with the good struts2 reference links.

+3


source to share


2 answers


If this property is in your action class, you don't need to use <s:property value="Description" />

it as it Description

will be available at the top of the value stack and you can use OGNL to fetch the value from the value-stack.This is what you need to do

<s:hidden  value="%{description}" name="test" />

      



Please make sure the value

hidden folder should be similar to the name of the property in your action class, as it will be resolved to either the recipient and the customizer in your action class or a public property defined in your action.

So this means value="%{description}"

OGNL will be transformed as getDescription()

it will try to find a getter in your action class to retrieve the property value.

+9


source


<s:hidden  value="%{description}" name="test" />

      



+2


source







All Articles