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)
原文地址:http://cbg23.blog.51cto.com/7201812/1651640