muziling
V2EX  ›  Java

springmvcr 的 ModelAttribute 注解怎么绑定 list

  •  
  •   muziling · Apr 18, 2020 · 2417 views
    This topic created in 2255 days ago, the information mentioned may be changed or developed.

    controller 里 public Result saveOrUpdate(@ModelAttribute ArrayList test) @ModelAttribute 要怎么绑定 list, 我试了报错,提示无法把 string 转 TestModel

    前端提交的编码是 Content-Type: application/x-www-form-urlencoded

    有没有例子,搜索了一圈,没找到

    2 replies    2020-04-20 08:45:37 +08:00
    putaozhenhaochi
        1
    putaozhenhaochi  
       Apr 18, 2020
    前台传 json 数组,后台直接 @RequestBody List<XXX> list 接收
    muziling
        2
    muziling  
    OP
       Apr 20, 2020
    @putaozhenhaochi 搞定了,传 jsonarray 不行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3864 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:20 · PVG 12:20 · LAX 21:20 · JFK 00:20
    ♥ Do have faith in what you're doing.