SpringMVC表單對象綁定到@ModelAttribute


支持綁定表單對象

jsp:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<
form:form id="itemForm" action="${pageContext.request.contextPath }/items/editItemSubmit.action" method="post" modelAttribute="items"> <form:input path="id" type="hidden"/> 修改商品信息: <table width="100%" border=1> <tr> <td>商品名稱</td> <td><form:input path="name" /></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="提交"/> </td> </tr> </table> </form:form>

controller:

@RequestMapping("/editItemSubmit")
    public String editItemSubmit(@ModelAttribute Items items,Model model){
        itemsService.updateItems(items);
        System.out.println(items);
        return "forward:list.action";
    }

 

重點是<form:input/>中的modelAttribute

擼的精盡人亡...


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM