struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Greenfield (JIRA)" <>
Subject [jira] [Created] (WW-4702) List based parameters no longer work when there is only one value.
Date Tue, 25 Oct 2016 20:01:00 GMT
Adam Greenfield created WW-4702:

             Summary: List based parameters no longer work when there is only one value.
                 Key: WW-4702
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.5.5
            Reporter: Adam Greenfield

If an action has a List parameter, but is only called with one value, the parameter is never

Consider the basic action below.

public class TestAction
	private List<SomeObject> object;

	public String execute()
		for (SomeObject user : object)
			System.out.println("as list" + user.field);
		return "success";

	public static class SomeObject{
		private String field;

		public void setField(String field)
			this.field = field;

	public List<SomeObject> getObject()
		return object;

	public void setObject(List<SomeObject> object)
		this.object = object;

Performing a GET on "/test.action?object.field=a" 
Expected outcome: "object" list should be populated with 1 object. with a field value of "a"
Actual Outcome: object list is empty.

Performing a GET on "/test.action?object.field=a&object.field=b" works as expected (list
has 2 entries). 

The following changes to [ParametersInterceptor|]
break this behavior. because [XWorkListPropertyAccessor|]
Expects an Array of strings for value (which was previously sent when HttpParameters was a
map instead of an Object).

if (value instanceof Parameter.File) {
     newStack.setParameter(name, value.getObject());
} else  if (value.isMultiple()) {
    newStack.setParameter(name, value.getMultipleValues());
} else {
     newStack.setParameter(name, value.getValue());

This message was sent by Atlassian JIRA

View raw message