Reputation: 405
I tried to pass a Javascript variable to a struts param tag and I did it as follow:
<script>
var userName ="sample";
</script>
<body>
<s:url action="myAction" id="myUrl">
<s:param name="userName" value="%{userName}" />
</s:url>
</body>
But, it didn't work. Would somebody tell me how to do it?
Upvotes: 0
Views: 1595
Reputation: 1264
You are confusing two very different things :
And as Struts will first render the html page, and then the page - html and javascript - will be interpreted by the browser, they is no way to pass a javascript variable to a Struts param.
in <s:param name="userName" value="%{userName}" />
, userName
should be a java bean
, server side.
Upvotes: 1