【发布时间】:2015-04-16 15:52:35
【问题描述】:
我今天想给你提出的问题是这样的:
一个请求到达一个控制器(在 Spring MVC 环境中),在那个控制器中,我想以某种方式拆分请求参数。我最初的方法是使用 @ModelAttribute 注释
public String processForm(@ModelAttribute Mouse tom, @ModelAttribute Mouse jerry)
但是通过这种方法,我将如何获得其他参数?这是有效的吗?
所以我想做这样的事情:
Mouse jerry = new Mouse();
BeanUtils.populate(jerry, request.getParameterMap());
//do something to remove the mice :) how?
Cat tom = new Cat();
BeanUtils.populate(cat, request.getParameterMap());
//do something to remove the cats how?
BeanUtils.populate(theRest, request.getParameterMap());
最后的问题是:如何通过尽可能少地遍历列表来有效地将请求拆分为 3 个不同的实体?
感谢您阅读本文,并希望得到答复。
【问题讨论】:
标签: java spring list spring-mvc dictionary