JavaScript的Struts2参数 [英] Struts2 parameter to javascript
问题描述
我有一个带有字段的struts2动作:private Long omradeId;
该字段有一个吸气剂.
I have a struts2 action with a field: private Long omradeId;
The field has a getter.
动作被发送到一个jsp,在该jsp中,我可以使用<s:property>
标签访问该字段.很好.
The action is sent to a jsp and within that jsp i can access the field using <s:property>
tag. Thats all good.
现在,我在jsp中也有一个部分,我在其中定义了<script>
.在该脚本中,我想创建一个变量,该变量将使用上述struts2字段作为值来构建URL.
Now i also have within the jsp a section where i define a <script>
. Within that script i would like to create a variable that will build a url with the above mentioned struts2 field as a value.
<script type="text/javascript">
var url = "/path/to/action?parameter1=";
</script>
如何将omradeId的值放在等号(=)后面?我尝试使用<s:property>
,但是没有用.
有什么建议吗?
How can i put the value of omradeId after the equals (=) sign? I tried using <s:property>
but that did not work.
Any suggestions?
推荐答案
这应该有效:
<script type="text/javascript">
var url = "/path/to/action?parameter1=<s:property value="omradeId">";
</script>
如果不是,则应检查该值是否不为null并在操作类中成功设置该值.
If not you should check if the value is not null and value is successfully set in your action class.
这篇关于JavaScript的Struts2参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!