0

I have the following code snippet in a jsp file:

<hr>
<form:form commandName="newTicketSale" id="reg" action="transactionResult.htm">
    <h3>Buy Movie Tickets:</h3>
    <form:label path="movieName">Movie Name:</form:label>
    <form:input path="movieName" />
    <form:errors class="invalid" path="movieName" />
    <form:label path="ticketPrice">Ticket Price:</form:label>
    <form:input path="ticketPrice" />
    <form:errors class="invalid" path="ticketPrice" />
     <input type="submit"> <br><br>
</form:form> 

I am using JPA tags in this jsp. Now, in the commandName "newTicketSale" there is another parameter called userId. In the jsp file itself I need to insert value ${name} in userId, so that in the Controller file when I am doing

@Valid @ModelAttribute("newTicketSale") MovieTicket newTicket

I can retrieve the value ${name} when I am doing newTicket.getUserId().

I don't know how to do this. Please help! Thanks in advance!

4

1 回答 1

0

您应该在下面使用modelattribute标签form:form

form:form method="post" action="example.html" modelAttribute="newTicketSale"

这样在表单中输入的值将被检索使用newTicket.getters

于 2013-11-01T09:51:47.780 回答