我的提交表单:
<form method="post" action="${pageContext.request.contextPath }/">
<div>
<label>User:</label>
<select name="customer">
<option value="">Select Customer</option>
<c:forEach var="c" items="${ cList }">
<option value="${ c.id }">${ c.name }</option>
</c:forEach>
</select>
</div><br>
<div>
<label>Hobby:</label>
<select name="product" multiple size="8">
<!-- <option value="">Select Items</option> -->
<c:forEach var="p" items="${ pList }">
<option value = "${ p.id }">${ p.productName }</option>
</c:forEach>
</select>
</div>
<br><br>
<input type="submit" value="Send">
</form>
我的控制器:
@RequestMapping(value = "/", method = RequestMethod.POST)
public String postHome(Model model, HttpServletRequest request, @ModelAttribute Transcation t){
transactionDao.addTransaction(t);
return "home";
}
在TransactionDaoImpl中:
@Override
@Transactional
public void addTranscation(Transcation t) {
session = sessionFactory.openSession();
session.save(t);
session.close();
}
根据您的想法,我必须进行哪种类型的修改才能执行插入操作。