Struts2 Dynamically Generate Hyperlinks Using Arraylist

I use struts and repeat the list of strings. I want to create a dynamic hyperlink based on the value of the prs element.

"s" is a list of iterators, and prs is one of the fields that should be added after s: url value example.com/web/default/100#data_tab

<td class="R0C0" > <a href="<s:url value="example.com/web/default/<s:property value="prs" />#data_tab"  />" target="_blank"><s:property value="prs" /></a>

So, for example, if there are two elements in the list, and the value of prs is 100 and 200, respectively. Then I want the url to be generated as follows:

s:url value example.com/web/default/100#data_tab
s:url value example.com/web/default/200#data_tab
+4
source share
1 answer

You cannot use Struts tags. You can use the OGNL expression to write the value prs.

<a href="<s:url value='example.com/web/default/%{prs}' />#data_tab" target="_blank"><s:property value="prs" /></a>
+2
source

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


All Articles