在 Struts2 中提交时提交 JS 函数值 [英] Submit JS function value on submit in Struts2
问题描述
如何通过 JavaScript function
将 s:form
中隐藏字段中设置的值传递给点击 s:submit
按钮的操作类这个 s:form
?
How to pass values set inside hidden field in s:form
by JavaScript function
to action class on click of s:submit
button of this s:form
?
推荐答案
值应为 CSV 格式,如 this一>回答.
The values should be in the CSV format like in this answer.
这也会让您了解应该绑定到隐藏字段的属性类型.例如,您可以将 List
或 Integer[]
用于设置值 25、27、28
的属性.
That will also give you an idea about type of property which you should bind to the hidden field. For example you can use List<Integer>
or Integer[]
for the property that set the values 25, 27, 28
.
Struts2 有一个内置转换器,可以自动将这些值转换为列表或数组.
Struts2 has a built-in converter that converts such values to the list or array automatically.
另请注意,如果安全管理器无法访问操作类中的实例变量(默认情况下),或者它没有像 getter 和 setter 这样的 public
访问器,则 OGNL 不能使用该实例变量.在 Struts2 中,提交的值由 params
拦截器填充到实例变量中,它确实调用了 OGNL 来完成这项工作.
Also note the instance variable in the action class can't be used by OGNL (by default) if it is not accessible by security manager or has not public
accessors like getters and setters. In Struts2 submitted values are populated to the instance variable by the params
interceptor which is indeed invokes OGNL to do the job.
这篇关于在 Struts2 中提交时提交 JS 函数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!