Struts2 Converting Enum Array fills array with single null value
- by Kyle Partridge
For a simple action class with these member variables:
...
private TestConverterEnum test;
private TestConverterEnum[] tests;
private List<TestConverterEnum> tList;
...
And a simple enum:
public enum TestConverterEnum {
A,
B,
C;
}
Using the default struts2 enum conversion, when I send the request like so:
TestConterter.action?test=&tests=&tList=&b=asdf
For test I get a null value, which is expected. For the Array and List, however, I get and Array (or list) with one null element. Is this what is expected? Is there a way to prevent this.
We recently upgraded our struts2 version, and we had our own converters, which also don't work in this case, so I was hoping to use the default conversion method. We already have code that is validating these arrays for null and length, and I don't want to have to add another condition to these branches. Is there a way to prevent this bevavior?