简体   繁体   English

在 Struts 2 中提交时提交 JS 函数值

[英]Submit JS function value on submit in Struts 2

如何通过 JavaScript function<s:form>隐藏字段内设置的值传递给点击此<s:form><s:submit>按钮的动作类?

The values should be in the CSV format like in this answer.值应采用 CSV 格式,如答案所示。

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 .例如,您可以将List<Integer>Integer[]用于设置值25, 27, 28的属性。

Struts2 has a built-in converter that converts such values to the list or array automatically. Struts2 有一个内置转换器,可以自动将这些值转换为列表或数组。

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.另请注意,如果安全管理器无法访问操作类中的实例变量(默认情况下),或者它没有public访问器(如 getter 和 setter),则 OGNL 无法使用该实例变量。 In Struts2 submitted values are populated to the instance variable by the params interceptor which is indeed invokes OGNL to do the job.在 Struts2 中,提交的值由params拦截器填充到实例变量中,它确实调用了 OGNL 来完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM