-1
このコードを使用してjspフォーム内で使用されるフォームデータを取得しています。jspフォームデータからレコードを保存するコントローラクラスのデータを保存するには
String product=request.getParameter("product");
String qty=request.getParameter("quantity");
String price=request.getParameter("price");
writer.println(product +" "+qty+" "+price);
どのように私は動的フォームを使用していますか。どのように私はコントローラクラス内のすべてのデータを取得できますか?
ビュークラスのコード、つまりJSPページです。
<script>
$(document).ready(function(){
$("button").on("click", function(){
var row = '<tr><td><input type="text" name="product" value="product..">'+
'</input></td><td><input type="number" name="quantity" value="quanty..">' +
' </input></td><td><input type="number" name="price" value="price.."> </input></td></tr>';
$("#customers").append(row);
});
});
</script>
</head>
<body>
<button type="button">Add More Products</button>
<form action="XmlServlet" method="get">
<table id="customers">
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<tr>
<td><input type="text" name="product" value="product.."></input> </td>
<td><input type="number" name="quantity" value="quanty.."></input></td>
<td><input type="number" name="price" value="price.."></input></td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</table>
</form>
ボタン操作を追加した後に、テキストフィールドに保存されたすべてのデータを取得する方法を教えてください。
リストの中に直接追加する方法。 –