Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从一个JSP获取数据到另一个JSP,其中JSP数据使用foreach循环显示_Java_Jsp_Jstl - Fatal编程技术网

Java 从一个JSP获取数据到另一个JSP,其中JSP数据使用foreach循环显示

Java 从一个JSP获取数据到另一个JSP,其中JSP数据使用foreach循环显示,java,jsp,jstl,Java,Jsp,Jstl,我使用foreach from会话变量在JSP中显示数据。该会话变量是产品的Arraylist。我想在用户单击一个产品时将数据从JSP发送到另一个JSP。我如何才能做到这一点> <div class="row"> <c:forEach items="${listProducts}" var="products"> <div class="column">

我使用foreach from会话变量在JSP中显示数据。该会话变量是产品的Arraylist。我想在用户单击一个产品时将数据从JSP发送到另一个JSP。我如何才能做到这一点>

<div class="row">
    <c:forEach items="${listProducts}" var="products">
    <div class="column">
        <div class="card">
        <form action="disp.jsp" method="GET">
                <h3>${products.pname}</h3>
                <p>price = &#8377;${products.price}</p>
                <p>Left out Stock: <b> ${products.quantity} </b> </p>
               <p> <input type="number" id="points" name="points" step="1" min="1" max="${products.quantity}"> </p>
                <p id="${products.pid}"></p>
                <p><button id="cartBtn">Add to Cart</button></p>
         </form>
         </div>
     </div>
    </c:forEach>
    
</div> 

${products.pname}
价格=₹${产品.价格}

遗漏库存:${products.quantity}

添加到购物车


如何将用户单击的特定产品id和数量发送到另一个JSP。它在for循环中,我不能直接使用
request.getParameter(“name”)

您可以将
${products.pid}
存储在一些隐藏的输入中,并且由于有关产品的详细信息已经在表单中,因此其中的输入将自动提交到另一个jsp页面。i、 e:

 <c:forEach items="${listProducts}" var="products">
    <div class="column">
        <div class="card">
           <form action="disp.jsp" method="GET">
                <h3>${products.pname}</h3>
                <p>price = &#8377;${products.price}</p>
                <p>Left out Stock: <b> ${products.quantity} </b> </p>
               <p> <input type="number" id="points" name="points" step="1" min="1" max="${products.quantity}"> </p>
               ///added hidden fields
                 <input type="hidden" name="id" value="${products.pid}"/>
                <p id="${products.pid}"></p>
               //add button type submit
                <p><button type="submit "id="cartBtn">Add to Cart</button></p>
         </form>
         </div>
     </div>
    </c:forEach>

${products.pname}
价格=₹${产品.价格}

遗漏库存:${products.quantity}

///添加了隐藏字段

//添加按钮类型提交 添加到购物车

并使用
request.getParameter(“id”)
获取id值,对于数量写入
request.getParameter(“点”)