sofs1
sofs1

Reputation: 4176

How can I submit a html form post that has several different iterated values?

This is a Spring MVC project.

So the following JSP

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
   <table>  
     <c:forEach items="${nameList}" var="studentList">
        <tr>
            <td><c:out value="${studentList.name}"/> ${studentList.regNo}</td>
        </tr>
     </c:forEach>
   </table>  

returns values like

Ramu
Somu
Mamu
Komu

I want to make each value as a post url, so that, if the user clicks any one link, I would like to submit as like the following jsp code does

<form method="post" action="number" id="number">
            <div style="text-align: center;" >                
                             <input  width="20" type="text" data-validation="numbers" id="regNo" name="regNo" size="30" maxLength="50" placeholder="Enter Register Number">                     
            </div>                      
    </form>   

I don't wanna do GET. How can I do this? Please help me.

Upvotes: 0

Views: 71

Answers (1)

Pradeep Kr Kaushal
Pradeep Kr Kaushal

Reputation: 1546

Use this
<td><a href='www.xyz.com:port/number?regNo=${studentList.regNo}><c:out value="${studentList.name}"/> </a></td>

And regNo you can get as the request parameter in controller
or Path parameter in your controller like

<td><a href='www.xyz.com:port/number/${studentList.regNo}><c:out value="${studentList.name}"/> </a></td>  

And modify your controller's configuration accordingly.

Upvotes: 1

Related Questions