In action I have a variable which has getter on it.
private String myActionVariable = "predefined....";
public String getMyActionVariable () {
return myActionVariable;
}
In jsp, I try to use my variable in this way:
<input type="button" class="styledButton"
onclick="javascript: doAjax('myActionName',false);"
value="${myActionVariable}"
But it is not shown. However, if I output this variable from the javascript code included within the same jsp file:
alert (${myActionVariable})
I will get the value of it….
Any idea please ? …
You can use a Standard
<input/>HTML Tag with an<s:property />Struts2 Tag for the value, like this:or a Struts2 Tag directly like this:
Note that with Struts2 Tag,
classattribute becomescssClass(andstylebecomescssStyle), and that%{}is the right OGNL syntax, instead of${}(that isJSTLsyntax)EDIT: when using Struts2, forget about JSTL, you won’t need them anymore.