码迷,mamicode.com
首页 > 编程语言 > 详细

Spring mvc 对象的对象的属性如何传到controller层

时间:2017-02-20 22:31:41      阅读:347      评论:0      收藏:0      [点我收藏+]

标签:mvc   for   trace   out   select   control   servlet   ack   value   

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层

标签:mvc   for   trace   out   select   control   servlet   ack   value   

原文地址:http://www.cnblogs.com/choiyubo163com/p/6421761.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!