重大发现 springmvc Controller 高级接收参数用法
2016-08-06 08:13
417 查看
1. 数组接收
页面:
?ids=1&ids=2&ids=3
2. list 接收
SystemUser.java
页面:
ps:
和struts2 的 ognl表达式不同之处在于:
@RequestMapping(value="deleteRole.json") @ResponseBody public Object deleteRole(String[] ids){ return systemService.deleteRole(ids); }
页面:
?ids=1&ids=2&ids=3
2. list 接收
package cn.zno.smse.pojo; import java.io.Serializable; import java.util.List; public class SystemUser implements Serializable { /** * */ private static final long serialVersionUID = 1L; private List<SystemRole> roleList; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column SMSE_USER.ID * * @mbggenerated */ private String id; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column SMSE_USER.NAME * * @mbggenerated */ private String name; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column SMSE_USER.USERNAME * * @mbggenerated */ private String username; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column SMSE_USER.PASSWORD * * @mbggenerated */ private String password; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column SMSE_USER.MOBILE * * @mbggenerated */ private String mobile; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column SMSE_USER.EMAIL * * @mbggenerated */ private String email; /** * This method was generated by MyBatis Generator. * This method returns the value of the database column SMSE_USER.ID * * @return the value of SMSE_USER.ID * * @mbggenerated */ public String getId() { return id; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column SMSE_USER.ID * * @param id the value for SMSE_USER.ID * * @mbggenerated */ public void setId(String id) { this.id = id == null ? null : id.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column SMSE_USER.NAME * * @return the value of SMSE_USER.NAME * * @mbggenerated */ public String getName() { return name; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column SMSE_USER.NAME * * @param name the value for SMSE_USER.NAME * * @mbggenerated */ public void setName(String name) { this.name = name == null ? null : name.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column SMSE_USER.USERNAME * * @return the value of SMSE_USER.USERNAME * * @mbggenerated */ public String getUsername() { return username; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column SMSE_USER.USERNAME * * @param username the value for SMSE_USER.USERNAME * * @mbggenerated */ public void setUsername(String username) { this.username = username == null ? null : username.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column SMSE_USER.PASSWORD * * @return the value of SMSE_USER.PASSWORD * * @mbggenerated */ public String getPassword() { return password; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column SMSE_USER.PASSWORD * * @param password the value for SMSE_USER.PASSWORD * * @mbggenerated */ public void setPassword(String password) { this.password = password == null ? null : password.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column SMSE_USER.MOBILE * * @return the value of SMSE_USER.MOBILE * * @mbggenerated */ public String getMobile() { return mobile; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column SMSE_USER.MOBILE * * @param mobile the value for SMSE_USER.MOBILE * * @mbggenerated */ public void setMobile(String mobile) { this.mobile = mobile == null ? null : mobile.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column SMSE_USER.EMAIL * * @return the value of SMSE_USER.EMAIL * * @mbggenerated */ public String getEmail() { return email; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column SMSE_USER.EMAIL * * @param email the value for SMSE_USER.EMAIL * * @mbggenerated */ public void setEmail(String email) { this.email = email == null ? null : email.trim(); } public List<SystemRole> getRoleList() { return roleList; } public void setRoleList(List<SystemRole> roleList) { this.roleList = roleList; } }
SystemUser.java
@RequestMapping(value="saveUserAdd.json") @ResponseBody public Object saveUserAdd(SystemUser user) { return systemService.saveUserAdd(user); }
页面:
<form> <tbody> <tr> <td colspan="2"> <b>用户角色</b> <hr> </td> </tr> <tr> <td> <input type="checkbox" name="roleList[0].id" value="21943DC037B343EDE053433210AC4939" id="roleList_0"> <label for="roleList_0">系统管理员</label> </td> <td> <input type="checkbox" name="roleList[1].id" value="38950038-53cd-11e6-9619-00163e001b41" id="roleList_1"> <label for="roleList_1">b</label> </td> </tr> <tr> <td> <input type="checkbox" name="roleList[2].id" value="4bcb3f3c-53cd-11e6-9619-00163e001b41" id="roleList_2"> <label for="roleList_2">c</label> </td> <td> <input type="checkbox" name="roleList[3].id" value="526dc5e4-53cd-11e6-9619-00163e001b41" id="roleList_3"> <label for="roleList_3">d</label> </td> </tr> </tbody> <form>
ps:
和struts2 的 ognl表达式不同之处在于:
框架 | name的值 |
Struts2 | user.roleList[0].id |
SpringMVC | roleList[0].id |
相关文章推荐
- SpringMVC Controller接收前台ajax的GET或POST请求返回各种参数
- SpringMVC Controller接收参数总结
- SpringMVC Controller接收前台ajax的GET或POST请求返回各种参数
- SpringMVC学习(二)高级参数绑定,拦截器,controller方法返回值
- web-view h5页面传递参数给小程序,小程序接收h5网页传过来的数据——微信web-view高级用法10
- SpringMVC Controller接收前台ajax的GET或POST请求返回各种参数
- Struts2中action接收参数的三种方法及ModelDriven跟Preparable接口结合JAVA反射机制的灵活用法
- Segue特殊用法:UITableViewController根据参数导航到不同的子页面或自身
- springMVC 接收参数的几种方法(转载于网络)
- 详解SpringMVC中Controller的方法中参数的工作原理[附带源码分析]
- springmvc请求接收参数的几种方法
- SpringMVC 接收对象参数
- springMVC教程(三)在controller中获取前台传递的参数
- springmvc请求接收参数的几种方法
- MVC3/4项目开发中遇到的ajax提交Json数据到后台Controller处理(接收参数:多重JSON)
- springmvc注解形式的开发参数接收
- springMVC 多个entity(User Famliy) 接收参数处理(属性名称一样)
- springMVC 多个entity(User Famliy) 接收参数处理(属性名称不一样)
- asp.net C# Button控件OnClientClick参数高级用法几则
- jsp接收相同复合参数 request.getParameterValues()用法