首页 > 编程语言 > 详细

spring MVC接收list,map,数组

时间:2015-05-15 18:03:53      阅读:185      评论:0      收藏:0      [点我收藏+]

spring mvc 接收复杂类型
1、接收数组
    1、jsp页面:
        <form action="home/hello" method="post">
          3:<input type="checkbox" name="ll" value="adfadf" id="myfile"><br/>       
          3:<input type="checkbox" name="ll" value="adfadf1111" id="myfile"><br/>       
          3:<input type="checkbox" name="ll" value="adfadf22222" id="myfile"><br/>       
        <input type="submit" value="提交"> </form>
    2、控制器:
        public String helloWord(String s,String [] ll)

2、接收list
    1)、实体类:
    public class LL {
        private List<String> ll;
        public List<String> getLl() {
            return ll;
        }
        public void setLl(List<String> ll) {
            this.ll = ll;
        }
    }
    2)、jsp页面
        <form action="home/hello" method="post">
          3:<input type="checkbox" name="ll[0]" value="adfadf" id="myfile"><br/>       
          3:<input type="checkbox" name="ll[1]" value="adfadf1111" id="myfile"><br/>       
          3:<input type="checkbox" name="ll[2]" value="adfadf22222" id="myfile"><br/>       
        <input type="submit" value="提交"> </form>
    3)、控制器
        public String helloWord(String s,LL l)

3、接收map
    1)、实体类
        public class LL {
            private Map<String, String> map;
            public Map<String, String> getMap() {
                return map;
            }
            public void setMap(Map<String, String> map) {
                this.map = map;
            }
        }
    2)、jsp页面
    <form action="home/hello" method="post">
          3:<input type="checkbox" name="map[‘a‘]" value="adfadf" id="myfile"><br/>       
          3:<input type="checkbox" name="map[‘b‘]" value="adfadf1111" id="myfile"><br/>       
          3:<input type="checkbox" name="map[‘c‘]" value="adfadf22222" id="myfile"><br/>       
        <input type="submit" value="提交"> </form>
    
    3)、控制器
        public String helloWord(String s,LL l)










spring MVC接收list,map,数组

原文:http://cbg23.blog.51cto.com/7201812/1651640

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!