Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Apart from concatenating the thing into a single commaseparated parameter and splitting it in the server side (which is a pretty <a href="https://stackoverflow.com/questions/954327/hidden-features-of-html/1978039#1978039">nasty</a> approach to be honest), you could also just send multiple parameter values along the same parameter name. It would then be available as a <code>String[]</code> array by <a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterValues(java.lang.String)" rel="nofollow noreferrer"><code>HttpServletRequest#getParameterValues()</code></a> on the parameter name. </p> <p>I don't do Spring, so here's a plain vanilla HTML/Servlet example to give the idea:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;ID: 12&lt;input type="hidden" name="id" value="12"&gt;&lt;/td&gt; &lt;td&gt;Qty: &lt;input type="text" name="qty"&gt;&lt;/td&gt; &lt;td&gt;Price: $100.00&lt;input type="hidden" name="price" value="100.00"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ID: 54&lt;input type="hidden" name="id" value="54"&gt;&lt;/td&gt; &lt;td&gt;Qty: &lt;input type="text" name="qty"&gt;&lt;/td&gt; &lt;td&gt;Price: $200.00&lt;input type="hidden" name="price" value="200.00"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ID: 8&lt;input type="hidden" name="id" value="8"&gt;&lt;/td&gt; &lt;td&gt;Qty: &lt;input type="text" name="qty"&gt;&lt;/td&gt; &lt;td&gt;Price: $500.00&lt;input type="hidden" name="price" value="500.00"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Servlet:</p> <pre><code>String[] ids = request.getParameterValues("id"); String[] qtys = request.getParameterValues("qty"); String[] prices = request.getParameterValues("price"); for (int i = 0; i &lt; ids.length; i++) { Long id = Long.parseLong(ids[i]); Integer qty = Integer.parseInt(qtys[i]); BigDecimal price = new BigDecimal(prices[i]); // ... } </code></pre> <p>I however highly question the need to send the price from client to server as well. I'd rather (re)calculate the price at the server side since the client has full control over the request parameters it sends and is thus able to change the parameter values outside the control of your form.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload