struts2 传递带 null 的数组

struts2 Passing Array with null

我正在使用 struts2 修复遗留系统,发现这种奇怪的行为,当传递数组时(从 html 表单提交),null/empty 的值得到从数组中删除。它发生在 Integer[] 类型上,但不会发生在 String[].

示例:

<s:form action="test">
   <s:textfield name="arr" value="1"/>
   <s:textfield name="arr" value=""/>
   <s:textfield name="arr" value="2"/>
</s:form>

它只会 return {1,2},而不是 {1,null,2},有什么解决方法吗?

发现我们有一个 struts 过滤器可以跳过其他函数所依赖的所有空值,所以我不能简单地删除它...

所以我最后添加了一个脚本,在传递参数之前将所有 null 更改为 -1,这不是一个好的解决方案,但它足够了