Show tag to use link in Struts2

I use display tag (Struts2) to populate the values. Please write my code.

<display:table name="sessionScope.studentList" export="true" requestURI="StudentDisplay"> <display:column property="studentFullName" title="Name"></display:column> <display:column property="studentMobile" title="Mobile No"></display:column> <display:column property="studentResidence" title="Residence No"></display:column> <display:column property="studentEmail" title="Email"></display:column> <display:column property="studentAddress" title="Address"></display:column> <display:column url="testAction.action" title="Map" value="Map Course"> </display:column> </display:table> 

what I want is the last column ie the Map should contain the link as the map rate, and by clicking I should get information about the selected record. eg. student of this particular record. Please help me with this. Thanks

+4
source share
1 answer

See http://www.displaytag.org/1.2/displaytag/tagreference.html for a tag reference.

You should be able to use the paramId and paramProperty attributes:

 <display:column url="testAction.action" paramId="id" paramProperty="studentId" title="Map" value="Map Course"/> 

This should generate a link with the following URL: testAction.action? id = if the bean has a getStudentId () method.

But overall, I prefer to create my links inside the display: column tag:

 <display:table ... id="theCurrentStudent"> ... <display:column title="Map"> <a href="<c:url value="testAction.action"/> <c:param name="id" value="${theCurrentStudent.studentId}"/> </c:url>">Click here</a> </display:column> </display:table> 

You can use any other tag inside the column tag to generate your link. The important thing is that the id attribute of the table tag allows you to define the pageContext variable that represents the current iteration element.

+3
source

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


All Articles