博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
重大发现 springmvc Controller 高级接收参数用法
阅读量:5354 次
发布时间:2019-06-15

本文共 6006 字,大约阅读时间需要 20 分钟。

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
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
getRoleList() { return roleList; } public void setRoleList(List
roleList) { this.roleList = roleList; }}
SystemUser.java
@RequestMapping(value="saveUserAdd.json")    @ResponseBody    public Object saveUserAdd(SystemUser user) {        return systemService.saveUserAdd(user);    }

页面:

用户角色

 

ps:

和struts2 的 ognl表达式不同之处在于:

 

框架 name的值
Struts2 user.roleList[0].id
SpringMVC roleList[0].id

转载于:https://www.cnblogs.com/zno2/p/5711607.html

你可能感兴趣的文章
spring Cache + Redis 开发数据字典以及自定义标签
查看>>
成功连上数据库顿感世界美好许多
查看>>
编程注意2
查看>>
《C++ Primer Plus》第12章 类和动态内存分配 学习笔记
查看>>
javascript中sort()排序方法总结
查看>>
实现聊天界面的代码
查看>>
自己生成一个NDK的浅析
查看>>
Excel数据导入到数据库
查看>>
jQuery最佳实践
查看>>
SELinux FAQ
查看>>
Java中synchronized同步的理解
查看>>
python 数值计算库
查看>>
java 服务重启 js 中被注释代码仍然执行
查看>>
我并不是不闻不问![C#]
查看>>
web前端经典小题
查看>>
AutoCAD如何倒角 倒圆角 倒直角
查看>>
Office PPT中如何插入flash
查看>>
C# Fade Form Effect With the AnimateWindow API Function
查看>>
golang多维数组的切片
查看>>
IP 网际协议
查看>>