简体   繁体   中英

Hidden value is in network call but not reaching to spring mvc controller

Passing a hidden field (start and end) from JSP to Spring MVC controller but its not reaching, with my debug point, the value checked is null but after completing the call, these values can be observed in the network call clearly. Why not passing the values of hidden fields with 'rental' object

JSP code,

<body>
    <center>
        <table border="1">
            <tr>
                <th><h2>Name</h2></th>
            </tr>
            <c:forEach items="${vehicles}" var="e">
                <tr>
                    <td>${e.vehicleName}</td>
                </tr>
            </c:forEach>
        </table>

        <br> <br>

        <form:form action="bookVehicle.web" method="post"
            modelAttribute="rental">

            <form:select path="vehicle.vehicleId">
                <form:option value="" label="-- Select" />
                <form:options items="${vehicles}" itemValue="vehicleId"
                    itemLabel="vehicleName" />
            </form:select>
            <br>
            <br>

            <b>Enter userId </b>
            <br>
            <br>
            <form:input path="user.email" />
            <br>
            <br>

            <form:hidden path="start" value="${start}" />
            <form:hidden path="end" value="${end}" />

            <input type="submit" value="book" name="bookVehicleBtn" />
        </form:form>

        <br> <br> <a href="index.web">Return To Home Page</a>
    </center>
</body>

@RequestMapping(value = "/bookVehicle.web", method = RequestMethod.POST, params = "bookVehicleBtn")
    public String bookVehicle(Model model, @ModelAttribute("rental") Rental rental, BindingResult error) {
        System.out.println(" inside controller ");
        model.addAttribute("message", rentalService.proceedBooking(rental));    
        return "message";       
    }

请确保模型类字段(开始和结束)的类型为字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM