How struts2 store forms elements in List on the Action ? (Prior Java5)

Here we have two choices when we work with list, either we go with the default type for the list elements or we specify the elements type explicitly in the .properties file for the respective action class. The default elements type for the list element is String.

here the list works the same way as the Array works but the difference here is, for the name[index] elements you do not need to initialized the list.
Means you do not need to initialize the any list on the Action class.
But assume here you want the weights list to store Integer values (Remember: before java 5 there was not generics). So for that you can specify the type of the values to be stored into the "List weight;". You can specify that type using below syntax.

Make a file named "ActionClassName-conversion.properties" and placed it at the location of the ActionClass file.
inside this properties file you have specify "Element-weights=java.lang.Integer" for storing Integer values into weights list.

=============

<s:form action="MyArraysAction">
<s:textfield name="weights" label="Weight"/>
<s:textfield name="weights" label="Weight"/>
<s:textfield name="weights" label="Weight"/>

<s:textfield name="names[0]" label="names"/>
<s:textfield name="names[1]" label="names"/>
<s:textfield name="names[2]" label="names"/>
<s:submit/>
</s:form>

=============

private List weights ;
public List getWeight() {
return weights;
}
public void setWeight(List weights) {
this.weights = weights;
}

private List names;
public List getNames() {
return names;
}
public void setNames(List names) {
this.names = names;
}

=============

WARNING
Never pre-initialize your List elements into the action class when you are using the typed element conversion mechanism supported by the 
ActionClassName-conversion.properties file.

One More Example of List
=============

If you have a form data something like following

<s:textfield name="users[0].username" label="Usernames"/>
<s:textfield name="users[1].username" label="Usernames"/>
<s:textfield name="users[2].username" label="Usernames"/>
or
<s:textfield name="users.username" label="Usernames"/>
<s:textfield name="users.username" label="Usernames"/>
<s:textfield name="users.username" label="Usernames"/>

=============
private List users ;
public List getUsers()
{
return users;
}

public void setUsers ( List users ) {
this.users=users;
}

=============

In this example we are submitting username value for three users and User is a separate class containing the username property.

so we need to provide the convenstion into the .properties for the user class.
i.e. Element_users = com.data.User

So When the OGNL come across the users[0].username or users.username then it will first find the users property on the actions class
then it will identity the type for the users property and then it will make USer object for it and then it will set the username value on that created object and then it will put that user object into the users list.
Here it will create total three user objects and will set individual username value on all three objects.