springmvc请求参数绑定集合类型

Account.java
public class Account implements Serializable {
    private String username;
    private String password;
    private Double money;

    private List<User> list;
    private Map<String,User> map;

param.jsp
<form action="param/saveAccount" method="post">
        姓名:<input type="text" name="username" /><br>
        密码:<input type="text" name="password" /><br>
        金额:<input type="text" name="money" /><br>

        user姓名:<input type="text" name="list[0].name" /><br>
        user年龄:<input type="text" name="list[0].age" /><br>

        user姓名:<input type="text" name="map['one'].name" /><br>
        user年龄:<input type="text" name="map['one'].age" /><br>
        <input type="submit" value="提交">
    </form>

ParameterController.java
    @RequestMapping("/saveAccount")
    public String testSaveAccount(Account account) {
        System.out.println("执行了...");
        System.out.println("account:"+account);
        return "success";
    }
account:Account{username='阿花', password='123', money=1000.0, list=[User{name='阿虎', age=21}], map={one=User{name='阿来', age=29}}}
全部评论

相关推荐

运营3年修炼中接简历辅导:你的科研项目经历里,只写了你的动作,没有写你的思考和成果,不要只写使用什么进行了什么,这等于罗列你的任务,简历是为了突出你的优秀,你在什么样的任务背景下,克服了什么样的困难,针对性地做了哪些事情,最后达成了什么成果(用数据体现你的成果和效率)
点赞 评论 收藏
分享
04-11 23:51
门头沟学院 Java
坚定的芭乐反对画饼_许愿Offer版:人人都能过要面试干嘛,发个美团问卷填一下,明天来上班不就好了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务