문제

I am using Struts 2 in that I have requirement I have to populate two different lists of same type as a dropdown box

Is it possible in Struts 2?

Demo code something like this:

<s:select list="{list1 , list2}" value="" />

Lists contain the same type of VO but with different data.

도움이 되었습니까?

해결책

First of all: you are better of doing that kind of things in action class not in JSP.

In JSP you can use <s:append> tag.

<s:append var="appendedLists">
  <s:param value="list1" />
  <s:param value="list2" />
</s:append>

<s:select list="#appendedLists" value="" />

다른 팁

Use the OGNL sequence operator comma(,). This operator allows to evaluate a sequence of OGNL expressions. For example

<s:set var="list1" value="{1,2}"/>
<s:set var="list2" value="{3,4}"/>
<s:select list="%{#list1.addAll(#list2), #list1}" />

add all elements from the second list via evaluating first expression, then return this list from the second expression as a result.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top