【问题标题】:Spring MVC 4 multi-selectSpring MVC 4 多选
【发布时间】:2017-07-31 19:55:07
【问题描述】:

我收到 400 错误 - 错误请求

类型状态报告

描述由于被认为是客户端错误(例如,格式错误的请求语法、无效的请求消息帧或欺骗性请求路由),服务器无法或不会处理请求。

问题来自:

<form:select path="children" multiple="multiple">
    <form:options items="${animals}" itemValue="key" itemLabel="name"/>
</form:select>

这里是控制器:

@RequestMapping(value = "/saveAnimal", method = RequestMethod.POST)
public ModelAndView saveAnimal(@ModelAttribute Animal animal,HttpServletRequest request) {
        if(animal.getKey() == null) {
            animalService.addAnimal(animal);
        }
        else animalService.updateAnimal(animal);

    return new ModelAndView("redirect:/animals");
}

我不确定如何从多选中检索值。没有这个字段一切正常。任何帮助将不胜感激。

【问题讨论】:

    标签: java spring jsp spring-mvc jsp-tags


    【解决方案1】:

    在你的表单中试试这个:

    <form:select path="children" multiple="true">
        <form:options items="${animals}" itemValue="key" itemLabel="name"/>
    </form:select>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 2012-12-05
      • 1970-01-01
      • 2016-10-11
      • 2011-05-18
      • 2016-07-30
      • 1970-01-01
      相关资源
      最近更新 更多