I have some code in JSP as below:
<c:iterate name="list" id="payment" index="idx">
<tr class="gRowEven"
_paid="<c:write name="payment" property="paid"/>">
Now my problem is that I want to call a method in a controller based on the variable _paid. I can do a request.setAttribute("_paid", _paid)
I am assuming it would work. But I am not supposed to do it that way. So I was wondering if there is any other way to do it?
You can pass that value to a hidden input field (on form submit)
then you controller can retrieve its value (using request.getParameter(‘newfield’), or a MVC framework provided method)
Or simply append to the URL if your controller takes GET request
By the way,
probably won’t work for you. Because this call is only executed when page is loaded, not when you submit the page. Also, when you submit a page, it will have a new fresh request
Edit: (this is what I meant by saying ‘pass that value to a hidden input field (on form submit)’)
Then _paid’s value will be passed with request in newfield parameter
And here’s how you get the parameter when you are using Spring MVC