0
我有Channel,Node和Channel_Node類。Spring MVC get multiple =「true」select作爲控制器中的集合
public class Node {
private String name;
private String address;
private Long idNode;
private String description;
private Organization organization;
private Region region;
private NodeType nodeType;
private Integer bound;
private Collection<ChannelNode> channelNodes;
....
public class Channel {
private Long idChannel;
private String name;
private String description;
private Long diameter;
private Long capacity;
private Long currentCapacity;
private ChannelType channelType;
private Long length;
private Collection<ChannelNode> channelNodes;
....
public class ChannelNode {
private Long idChannelNode;
private String name;
private Node node;
private Channel channel;
....
和我有下面的Spring形式:選擇我addChannel.jsp
<form:select path= "channelNodes" multiple="true" id="nodeBox">
內,我需要得到channelNodes作爲一個集合並將其設置爲我的頻道對象的創建方法在我的控制器類。
@RequestMapping(value = "/create", method = RequestMethod.POST)
public String create(HttpServletRequest request, @Valid @ModelAttribute("channel") Channel channel,
BindingResult result) {
LOG.info(String.format("Create new channel: %s", channel));
/*
* if (result.hasErrors()) { return CHANNEL_ADD_VIEW; } else {
*/
ChannelType channel_type = channelTypeService.getOne(Long.parseLong(request.getParameter("channelType")));
channel.setChannelType(channel_type);
channelService.create(channel);
return CHANNEL_LIST_VIEW_REDIRECT;
// }
}