SpringMVC传递参数
老师,请问SpringMVC不是不直接支持map集合类型来传递参数吗,为什么在报销单处理的控制器中,很多控制器的方法参数都是map类型?
@RequestMapping("/to_add")
public String toAdd(Map<String,Object> map){
map.put("items", Contant.getItems());
map.put("info",new ClaimVoucherInfo());
return "claim_voucher_add";
}
@RequestMapping("/add")
public String add(HttpSession session, ClaimVoucherInfo info){
//设置报销单的创建者编号,我们首先就要从session中获取登录对象
Employee employee = (Employee)session.getAttribute("employee");
info.getClaimVoucher().setCreateSn(employee.getSn());
claimVoucherBiz.save(info.getClaimVoucher(),info.getItems());
return "redirect:deal";
}
@RequestMapping("/detail")
public String detail(int id, Map<String,Object> map){
map.put("claimVoucher",claimVoucherBiz.get(id));
map.put("items",claimVoucherBiz.getItems(id));
map.put("records",claimVoucherBiz.getRecords(id));
return "claim_voucher_detail";
}
@RequestMapping("/self")
public String self(HttpSession session, Map<String,Object> map){
Employee employee = (Employee)session.getAttribute("employee");
map.put("list",claimVoucherBiz.getForSelf(employee.getSn()));
return "claim_voucher_self";
}
@RequestMapping("/deal")
public String deal(HttpSession session, Map<String,Object> map){
Employee employee = (Employee)session.getAttribute("employee");
map.put("list",claimVoucherBiz.getForDeal(employee.getSn()));
return "claim_voucher_deal";
}
@RequestMapping("/to_update")
public String toUpdate(int id,Map<String,Object> map){
//修改报销单
map.put("items", Contant.getItems());
ClaimVoucherInfo info =new ClaimVoucherInfo();
info.setClaimVoucher(claimVoucherBiz.get(id));
info.setItems(claimVoucherBiz.getItems(id));
map.put("info",info);
return "claim_voucher_update";
}
@RequestMapping("/update")
public String update(HttpSession session, ClaimVoucherInfo info){
Employee employee = (Employee)session.getAttribute("employee");
info.getClaimVoucher().setCreateSn(employee.getSn());
claimVoucherBiz.update(info.getClaimVoucher(),info.getItems());
return "redirect:deal";
}
@RequestMapping("/submit")
public String submit(int id){
claimVoucherBiz.submit(id);
return "redirect:deal";
}
@RequestMapping("/to_check")
public String toCheck(int id,Map<String,Object> map){
map.put("claimVoucher",claimVoucherBiz.get(id));
map.put("items",claimVoucherBiz.getItems(id));
map.put("records",claimVoucherBiz.getRecords(id));
//传递一个报销单处理记录
DealRecord dealRecord = new DealRecord();
dealRecord.setClaimVoucherId(id);
map.put("record",dealRecord);
return "claim_voucher_check";
}
正在回答 回答被采纳积分+1
这个应该是SSM框架中可以直接使用map集合传值,之前springMVC中需要绑定。你可以看一下这个:https://blog.csdn.net/liangshilin/article/details/82724062
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星