重大发现 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数据同步redis
from: http://www.cnblogs.com/zhxilin/archive/2016/09/30/5923671.html 在服务端开发过程中,一般会使用MySQL等关系型数据库作为最终 ...
- SpringMVC知识(1)
1.SpringMVC的工作流程 流程 : 1.用户发送请求至前端控制器DispatcherServlet 2.DispatcherServlet收到请求调用HandlerMapping处理器映射器. ...
- Why We Worry and What to Do About It
Note: My new book Atomic Habits is available to preorder now. Click here to learn more. The Evolutio ...
- mysql 建库建表建用户
1.创建数据库 create database school; 2.使用数据库 Use school; 3.创建用户 create user jame@localhost identified by ...
- sql查询job
use msdb go --if object_id('tempdb..#SqlAgentJob') is not null -- drop table #SqlAgentJob --go decla ...
- 进程间通信-Queue
进程间通信-Queue Process之间有时需要通信,操作系统提供了很多机制来实现进程间的通信. 1. Queue的使用 可以使用multiprocessing模块的Queue实现多进程之间的数据传 ...
- Fb 第三方接口
1.Facebook ID? User ID / https://www.piliapp.com/facebook/id/?url=https%3A%2F%2Fwww.facebook.com%2Fz ...
- linux 安装SAMtools,bcftools,htslib,sratoolkit,bedtools,GATK,TrimGalore,qualimap,vcftools,bwa
--------------------安装Samtools---------------------------------------------------------------------- ...
- swift VFL - 父视图是scrollview 注意点
1. scrollview 添加 子控件, 必须设置 宽度和高度, 他自己无法撑满2. scrollview的子空间的约束 只能相对于 左边 的顶部, 无法设置右边和底部的约束 3. 设置最小距离 ...
- nginx反向代理部署与演示(二)
我们把LB01作为负载均衡器,WEB01和WEB02作为两台web服务器. WEB01与WEB02虚拟主机配置如下: 我们修改nginx下的conf/nginx.conf文件,在http{}中 ...