Spring MVC 提交带有点分隔的参数

0
(0)
 @InitBinder("orderTargetingsVo")
    public void initBinder(WebDataBinder webDataBinder) {
        webDataBinder.setFieldDefaultPrefix("targeting.");
    }

    @ResponseBody
    @RequestMapping("/add.do")
    public Map<String, Object> addAdOrder(AdOrderVo adOrderVo, OrderTargetingsVo orderTargetingsVo) {

        result.put("msg", "操作成功!");
        result.put("success", true);
        return result;
    }

重点就是需要配置参数@InitBinder告诉当请求的方法上有orderTargetingsVo这个名称的参数的时候,参数普遍有一个前缀。意思就是给这个vo里面去set值的时候使用没有这个前缀的名称与vo里面的set方法去匹配;

这篇文章有用吗?

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位评论此文章。

很抱歉,这篇文章对您没有用!

让我们改善这篇文章!

告诉我们我们如何改善这篇文章?

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据