是否可以在mySQL / JSP中使用URL参数? [英] Is it possible to use URL parameters with mySQL/JSP?
问题描述
当您点击购买时,您将点击购买的特定行的商品代码并将其发送到下一个pad jsporder.jsp。
< sql:query var =result>
从库存中选择*;
< / sql:query>
< table border =1width =100%>
< tr>
代码< / th>
< th>作者< / th>
< th>说明< / th>
其他字段(Probs价格)< / th>
< th> Item Stock< / th>
Order Storage< / th>
th购买选项< / th>
< / tr>
< c:forEach var =rowitems =$ {result.rows}>
< tr>
< td>< c:out value =$ {row.item_code}/>< / td>
< td>< c:out value =$ {row.item_author}/>< / td>
< td>< c:out value =$ {row.item_description}/>< / td>
< td>< c:out value =$ {row.item_price}/>< / td>
< td>< c:out value =$ {row.item__stock_count}/>< / td>
< td>< c:out value =$ {row.item_order_count}/>< / td>
< td>< a href =jsporder.jsp?item_code = $ {row.item_code}>购买!< / a>< / td>
< td>< a
< / tr>
< / c:forEach>
< / table>
< / div>
在下一页中,我想使用类似request.getParameter(item_code);方法,但对于mySQl。
mySQL代码现在:(这是在jsporder.jsp页面上)
< sql:query var =result>
从库存中选择item__stock_count
where item_code =AA01-002;
< / sql:query>
现在物品代码被设置为静态AA01-002,但我希望它取决于购买什么按钮,你点击。那么是否有如下所示:
< sql:query var =result>
从库存中选择item__stock_count
where item_code =request.getParameter(item_code)
< / sql:query>
因此,项目代码可以是一系列不同的字符,具体取决于点击哪个按钮。
您可以使用scriplet
<%
String itemCode = request.getParamenter( item_code);
%>
< sql:query var =result>
从库存中选择item__stock_count
where item_code =$ {itemCode }
My code: This code first creates a table. The table is then populated with data from mySQL database. My problem is at the last bit with the ahref.
When you click buy it will take the item code for that specific row the buy you click is in and sends it to the next pad jsporder.jsp.
<sql:query var="result">
select * from inventory;
</sql:query>
<table border="1" width="100%">
<tr>
<th>Code</th>
<th>Author</th>
<th>Description</th>
<th>Other field(Probs price)</th>
<th>Item Stock</th>
<th>Order Stock</th>
<th>Buy option </th>
</tr>
<c:forEach var = "row" items = "${result.rows}">
<tr>
<td><c:out value = "${row.item_code}"/></td>
<td><c:out value = "${row.item_author}"/></td>
<td><c:out value = "${row.item_description}"/></td>
<td><c:out value = "${row.item_price}"/></td>
<td><c:out value = "${row.item__stock_count}"/></td>
<td><c:out value = "${row.item_order_count}"/></td>
<td><a href="jsporder.jsp?item_code=${row.item_code}">Buy!</a></td>
<td><a
</tr>
</c:forEach>
</table>
</div>
On the next page I want to use something like the request.getParameter("item_code"); method but for mySQl.
Code for mySQL now: (This is on jsporder.jsp page)
<sql:query var="result">
select item__stock_count from inventory
where item_code="AA01-002";
</sql:query>
Now the item code is set at static AA01-002 but I want it to be dependent on what buy button you click. So is there anything such as:
<sql: query var="result">
select item__stock_count from inventory
where item_code="request.getParameter("item_code")
</sql:query>
So the item code can be a range of different characters depending on what button is clicked
you can use the scriplet
<%
String itemCode = request.getParamenter("item_code");
%>
<sql: query var="result">
select item__stock_count from inventory
where item_code="${itemCode}"
</sql:query>
这篇关于是否可以在mySQL / JSP中使用URL参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!