Answer the question
In order to leave comments, you need to log in
How to pass post request using Spring MVC methods?
I have a panel in which there are numbers and comboboxes, next to each of them there is a sumbit button.
I need to transfer the selected value from the combobox and the number (let's say id) by clicking on this button.
How can this be implemented with spring mvc method?
Snippet using jstl:
<c:forEach items="${list}" var="user">
<tr>
<td>${user.id}</td>
<td>${user.login}</td>
<td>${user.email}</td>
<td>${user.role}</td>
<td><form method="post" action="changerole">
<label> Изменить роль на: </label>
<select>
<c:forEach items="${roles}" var="role">
<option id="role" value="${role.name()}">${role}</option>
</c:forEach>
</select> <input type="submit" value="Изменить роль"></p>
</form></td>
</tr>
</c:forEach>
Answer the question
In order to leave comments, you need to log in
In order not to create classes for spring forms, I decided to use ajax and json. Changed all id to classes and sent the following object:
var data= {
"id": $(this).children("input.id").val(),
"role" : $(this).children("select.role").val()
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question