0
    @RequestMapping(value = "/Fin_AddCheckBook", method = RequestMethod.POST)
public @ResponseBody
JsonResponse addCoaCategory(
        @RequestParam(value="checkbookNumber", required=true) String checkbookNumber,
        @RequestParam(value="checkbookName", required=true) String checkbookName,
        @RequestParam(value="startNumber", required=true) long startNumber,
        @RequestParam(value="bankId", required=true) long bankId,
        @RequestParam(value="currencyId", required=true) long currencyId,
        @RequestParam(value="noOfLeves", required=true) int noOfLeves,
        @RequestParam(value="alertAt", required=true) int alertAt,
        @RequestParam(value="isActive", required=true) int isActive, Map map, Model model) {

我有两个表格在一个表格中!我想通过指定 @RequestParam(value="startNumber", required=true) long startNumber 来按名称接收第一个表元素; 地图中的第二个表格元素,即地图地图

如何接收一些带有名称的参数和地图中的所有其他元素?

4

1 回答 1

0
Create your own objects : 

public class MyMap {
    private String myObject1; // dont forget that these names should be same as @RequestParam values

    private Integer myObject2;

    //setters and getters. they are must!!

}

public class MyMap2 {
    private String my1;

    private Integer my2;

    //setters and getters. they are must!!

}

现在将此对象作为控制器方法的参数。

@RequestMapping(value = "/Fin_AddCheckBook", method = RequestMethod.POST)
public @ResponseBody JsonResponse addCoaCategory(MyMap myMap, MyMap2 myMap2, BindingResult result) {
    if (!result.hasErrors()) {
        // work with myMap myMap2
    }
}
于 2013-05-15T14:50:08.630 回答