首页 > 代码库 > Spring mvc 对象的对象的属性如何传到controller层
Spring mvc 对象的对象的属性如何传到controller层
jsp页面的form:
<form class="am-form" id="addForm" action="addStudent" method="post"> <div class="am-g am-margin-top"> <div class="am-u-sm-4 am-u-md-2 am-text-right">学生编号</div> <div class="am-u-sm-8 am-u-md-4 am-u-end col-end"> <input type="text" name="studentno"/> </div> </div> <div class="am-g am-margin-top"> <div class="am-u-sm-4 am-u-md-2 am-text-right">学生姓名</div> <div class="am-u-sm-8 am-u-md-4 am-u-end col-end"> <input type="text" name="studentname"/> </div> </div> <div class="am-g am-margin-top"> <div class="am-u-sm-4 am-u-md-2 am-text-right">学生系别</div> <div class="am-u-sm-8 am-u-md-4"> <select name="department.departmentid" > <c:forEach var="department" items="${DEPARTMENTLIST}"> <option value="${department.departmentid}">${department.departmentname}</option> </c:forEach> </select> </div> <div class="am-hide-sm-only am-u-md-6">*必填</div> </div> </form>
<select name="department.departmentid" >
注意这里不能写成
<select name="departmentid" >
controller层代码:
@RequestMapping("addStudent") public void addStudent(Student student,HttpServletResponse response){ try { System.out.println(student); studentdao.addStudent(student); response.sendRedirect("listStudent"); } catch (Exception e) { e.printStackTrace(); } }
Spring mvc 对象的对象的属性如何传到controller层
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。