需要将变量值从jsp传递给java类

时间:2015-11-09 15:33:40

标签: java jsp

这是我的.jsp文件

    <form action="/loungeHotel/addressValidation" method="post" id="form1">
    <div class="row">
    <input type="text" name="emailId" value="${studentData.address.emailId}" class="input">
    </div>    
</form>
        <c:set var="totalBasePrice" value="${0}"/> 
        <c:forEach items="${listOfProducts}" var="productData">
        <c:set var="basePrice" value="${productData.basePrice*productData.quantity}"/>
        <c:set var="totalBasePrice" value="${basePrice + totalBasePrice}"/>
        </c:forEach>
        <li>Total Price :${totalBasePrice}</li>

我想将$ {totalBasePrice}值传递给我的java文件

这是我的java类

   @RequestMapping(value = "/addressValidation", method = RequestMethod.POST)
    private String addressValidation(HttpSession httpSession ,final Model model){

    System.out.println("here i want to print the value of totalBasePrice");
            return "CheckOutPage";
    } 

我尝试了什么?

<form action="/loungeHotel/addressValidation" method="post" id="form1">
        <div class="row">
        <input type="text" name="emailId" value="${studentData.address.emailId}" class="input">
        </div>    
    </form>
            <c:set var="totalBasePrice" value="${0}"/> 
            <c:forEach items="${listOfProducts}" var="productData">
            <c:set var="basePrice" value="${productData.basePrice*productData.quantity}"/>
            <c:set var="totalBasePrice" value="${basePrice + totalBasePrice}"/>
            </c:forEach>
            <li>Total Price :${totalBasePrice}</li>
            <%
                session.setAttribute("base","${totalBasePrice}");
                                %>

和java

        @RequestMapping(value = "/addressValidation", method = RequestMethod.POST)
                private String addressValidation(HttpSession httpSession ,final Model model){

        System.out.println(httpSession.getAttribute("base"));
                return "CheckOutPage"; 
  }

****并打印“$ {totalBasePrice}”****

0 个答案:

没有答案