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