Passing Struts 2 List Parameters

How to pass a list of integers using s: a href and param tags in Struts 2?

POJO example:

private List<Integer> myList = new ArrayList<Integer>();

public List<Integer> getMyList() {
    return myList;
}

public void setMyList(List<Integer> myList) {
    this.myList = myList;
}

Example JSP Page:

<s:url id="testUrl" action="testAction">
   <s:param name="myList" value="%{myList}" />
</s:url>
<s:a href="%{testUrl}">Test Link</s:a>

When I click "Test Link", the form submits the following for myList:

[1 + 2 + 3 + 4 + 5]

This causes Struts to redirect the input page. This is not the desired behavior. Does anyone have any suggestions on how to properly pass a list of integers using Struts tags?

+3
source share
1 answer

The tag parameter calls toString in the list to put the parameter in the URL, if I remember correctly. Therefore, an action that only the list should receive gets the string.

, , .

0

Source: https://habr.com/ru/post/1771524/


All Articles