重大发现 springmvc Controller 高级接收参数用法
1. 数组接收
@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 高级接收参数用法的更多相关文章
- springmvc controller层接收List类型的参数
Spring MVC在接收集合请求参数时,需要在Controller方法的集合参数里前添加@RequestBody,而@RequestBody默认接收的enctype (MIME编码)是applica ...
- SpringMVC Controller接收参数总结
本文中Controller的开发环境如下表格所示,Maven对应POM配置如下代码段所示: 系统/工具 版本号OS Windows 7 Home BasicJava 1.7.0_79Eclipse M ...
- springmvc 传递对象数组参数 property path is neither an array nor a List nor a Map
Spring MVC 3: Property referenced in indexed property path is neither an array nor a List nor a Map ...
- springmvc Controller接收前端参数的几种方式总结
(1) 普通方式-请求参数名和Controller方法的参数一致 @Controller @RequestMapping("/param") public class TestPa ...
- SpringMVC详解一、@RequestMapping注解与Controller接收参数
SpringMVC详解一.@RequestMapping注解与Controller接收参数 https://blog.csdn.net/mxcsdn/article/details/80719258 ...
- 【springmvc Request】 springmvc请求接收参数的几种方法
通过@PathVariabl注解获取路径中传递参数 转载请注明出处:springmvc请求接收参数的几种方法 代码下载地址:http://www.zuida@ima@com/share/1751862 ...
- springmvc 传递和接收数组参数
java url中如何传递数组,springMVC框架controller类如何接收数组参数? 下面介绍一下URL中传递数组参数方法: dd.do?titles[]=col1&titles[] ...
- springmvc接收参数
springmvc执行流程 搭建ssm框架:http://www.cnblogs.com/liyafei/p/7955413.html 1:从表单中接收 普通请求参数 结构目录 role.html 1 ...
- SpringMVC中控制器接收JSP页面表单的参数接收方式详解及细节注意(400错误)
控制器方法中参数的接收 (1)以前的参数接收: String param = req.getParameter(name): (2)SpringMVC简化这个操作,只需要给控制器方法添加参数即可 a ...
随机推荐
- tensorflow Process finished with exit code 137 (interrupted by signal 9: SIGKILL) 错误
Process finished with exit code 137 (interrupted by signal 9: SIGKILL) 在使用tensorflow自带的数据集做手写数字识别的时候 ...
- Mysql 获取当月和上个月第一天和最后一天的解决方案
#获取当前日期select curdate(); #获取当月最后一天select last_day(curdate()): #获取本月的第一天select date_add(curdate(),int ...
- sql server判断是否为null
sql server 替换null:isnull(arg,value) 如:select isnull(price,0.0) from orders ,如果price为null的话,用0.0替换 与n ...
- jQuery中的几个模块总结
Query插件,以备并希望在前端方面有所长进.请批评指正. 一,类型判断全解 JQuery判断类型扩展方法:$.type() /*type: function( obj ) { if ( obj == ...
- Validate the date format
Validate the date format function checkdate(input) { var validformat = /^\d{2}\/\d{2}\/\d{4}$/; //Ba ...
- sparkSQL、dataframe
http://www.aboutyun.com/forum.php?mod=viewthread&tid=12358&page=1 空值填充:http://spark.apache.o ...
- HTTP request failed! HTTP/1.1 411 Length Required
$opts = array( 'http'=>array( 'method'=>"POST", 'header' => 'Content-Length: 0' / ...
- cmd 字符串截取
@echo off set "url=www.mzwu.com" echo 1.字符串截取 echo %url:~4,4% echo %url:~4,-4% echo %url:~ ...
- runloop 和 CFRunLoop - 定时器 - NSTimer 和 GCD定时器
1. 2. #import "ViewController.h" @interface ViewController () @property (nonatomic, strong ...
- [leetcode]426. Convert Binary Search Tree to Sorted Doubly Linked List二叉搜索树转有序双向链表
Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers ...