I have set a Struts variable in my JSP:
<s:set var="actionName" value="stockCountFind.action" scope="request" />
In the javascript function I access it using
function getAttributeAndGoToAction() {
var actionName = <s:property value="#actionName"/>;
alert(actionName);
}
But when I try to call the JS function. It says it isn't defined.
答案 0 :(得分:0)
尝试使用此:
function getAttributeAndGoToAction()
{
var actionName = "%{actionName}";
alert(actionName);
}
只需用 %{ 和 }
包围变量我以这种方式在.jsp中使用这样的变量:
<s:set var="myVar"><c:out value="${myVar}"/></s:set>
<s:a href="%{myVarRef}" title="%{myVar}" target="_blank">
...
</s:a>