Action class
public class ProductAction extends ActionSupport implements Preparable {
private Document product;
}
Model
public class Document {
private Map<String, Object> properties;
}
JSP
<s:textfield name="product.properties.PRODUCT_NAME"
value="% {product.properties..PRODUCT_NAME}"
label="%{getText('label.PRODUCT_NAME')}" size="40" />
<s:textfield name="product.properties.SUPPLIER"
value="%{product.properties.SUPPLIER}"
label="%{getText('label.SUPPLIER')}" size="40" />
Product_name and Supplier are populated as Array in Map (Map<String, String[]>
) properties.
PRODUCT_NAME : [Ljava.lang.String;@4e96ac47]
SUPPLIER : [Ljava.lang.String;@1c90a278]
If I change the Document->properties to Map<String, String>
it works fine.
But I want to retain Document->properties as Map<String, Object>
because of other datatypes.
How to solve this issue, I want form data to be populated as String
instead of String[]
.
I don't have multiple text fields with the same name.
Solution: we can apply type Converter to a bean or model http://struts.apache.org/release/2.3.x/docs/type-conversion.html#TypeConversion-ApplyingaTypeConvertertoabeanormodel