重大发现 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 ...
随机推荐
- MySQL的事务处理及隔离级别
事务是DBMS得执行单位.它由有限得数据库操作序列组成得.但不是任意得数据库操作序列都能成为事务.一般来说,事务是必须满足4个条件(ACID) 原子性(Autmic):事务在执行性,要 ...
- MonoDevelop 设置
菜单:Tools->Options Text Editor Behavior Automatic behaviors × enable on the fly code formatting Sy ...
- 第一个struct2程序(2)
第三步 需要使用ActionForm了.在Struts1.x中,必须要单独建立一个ActionForm类(或是定义一个动作Form),而在Struts2中ActionForm和Action已经二合一了 ...
- struts2的运行流程
流程: 1:url 提交到tomcat http://localhost/s2/firstAction 2:tomcat 根据工程名 去 webapps 文件夹下找到对应工程 3:找web.xml S ...
- URL转义字符
[URL转义字符] 参考:http://www.cnblogs.com/jiunadianshi/articles/2353968.html
- Javascript读写CSS属性
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- SQL Server多条件查询的实现
SQL Server多条件查询的实现 SQL Server多条件查询我们经常会用到,下面就教您如何使用存储过程实现SQL Server多条件查询,希望对您学习SQL Server多条件查询方面有所帮助 ...
- rapidjson使用
Value构造 Value对象最好先声明后初始化,如果声明直接初始化可能出错. rapidjson::Value a; a = val[i]; Value传参 Value传参,最好显式使用右值,如st ...
- 百度Cafe原理--Android自动化测试学习历程
主要讲解内容及笔记: 一.Cafe原理 Cafe是一款自动化测试框架,解决问题:跨进程测试.快速深度测试 官网:http://baiduqa.github.io/Cafe/ Cafe provides ...
- 【校招面试 之 C/C++】第19题 C++ STL(一)
容器名称 说明 vector 典型的序列容器,C++标准严格要求次容器的实现内存必须是连续的,唯一可以和标准C兼容的stl容器,任意元素的读取.修改具有常数时间复杂度,在序列尾部进行插入.删除是常 ...