title: Many-To-Many binding issue with <form:select> in Spring
body: <p>When I load page for create a new article, all categories is displayed in select box.</p>
  
  <p>When I complete form for a new article and click on the submit button, it saves all data from form to the database but categories isn't joined with an article.</p>
  
  <p>Do you understand me what I think? What could be an issue?</p>
  
  <p><strong>ArticleController.class</strong></p>
  
  <pre><code>@Controller
  public class ArticleController {
  
  @Autowired
  ArticleService articleService;
  
  @Autowired
  CategoryService categoryService;
  
  @Autowired
  UserService userService;
  
  @ModelAttribute("article")
  public Article construct() {
      return new Article();
  }
  
  /**
   * Method displays page with all articles, categories and users
   * (articles.jsp)
   * */
  @RequestMapping("/admin/articles")
  public String articles(Model model) {
      model.addAttribute("articles", articleService.findAll());
      model.addAttribute("categories", categoryService.findAll());
      model.addAttribute("users", userService.findAll());
      return "articles";
  }
  
  /**
   * Method for display article's detail (article-detail.jsp)
   * */
  @RequestMapping("/admin/articles/{id}")
  public String userDetail(Model model, @PathVariable Integer id) {
      model.addAttribute("articles", articleService.findAll());
      model.addAttribute("article", articleService.findById(id));
      return "article-detail";
  }
  
  /**
   * Method for display article's add page (article-add.jsp)
   * */
  @RequestMapping("/admin/articles/new")
  public String articleAdd(Model model) {
      model.addAttribute("articles", articleService.findAll());
      model.addAttribute("categories", categoryService.findAll());
      model.addAttribute("users", userService.findAll());
      return "article-add";
  }
  
  /**
   * Method for save article
   * */
  @RequestMapping(value = "/admin/articles/new", method = RequestMethod.POST)
  public String saveArticle(@ModelAttribute("article") Article article,
          BindingResult result) {
      Date publishDate = new Date();
      article.setPublishDate(publishDate);
      articleService.save(article);
      return "redirect:/admin/articles.html?success=true";
  }
  
  /**
   * Binder for required date format
   * */
  @InitBinder
  public void initBinder(WebDataBinder webDataBinder) {
      SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm");
      dateFormat.setLenient(false);
      webDataBinder.registerCustomEditor(Date.class, "publishDate",
              new CustomDateEditor(dateFormat, false));
  }}
  </code></pre>
  
  <p><strong>article-add.jsp</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%&gt;
  
  &lt;%@ include file="../layouts/taglibs.jsp"%&gt;
  
  &lt;form:form commandName="article" cssClass="form-horizontal"&gt;
  &lt;div class="form-group"&gt;
      &lt;form:hidden path="id" class="form-control input-sm" /&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="title" class="col-sm-2 control-label"&gt;Titulek&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          &lt;form:input path="title" cssClass="form-control" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="content" class="col-sm-2 control-label"&gt;Text&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          &lt;form:textarea path="content" cssClass="form-control" rows="10" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="categories" class="col-sm-2 control-label"&gt;Kategorie&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          &lt;form:select path="categories" items="${categories}" itemLabel="name" itemValue="id"      multiple="true" cssClass="form-control" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="user" class="col-sm-2 control-label"&gt;Uživatel&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          &lt;form:select path="user.id" items="${users}" value="${user.id}" itemLabel="name" itemValue="id"  cssClass="form-control" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
      &lt;div class="col-sm-2"&gt;
          &lt;input type="submit" value="Uložit" class="btn btn-primary"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Category.class</strong></p>
  
  <pre><code>@Entity
  public class Category {
  
  @Id
  @GeneratedValue
  private Integer id;
  
  @Size(min=3, max=20, message="Název musí obsahovat 3-20 znaků!")
  private String name;
  
  @ManyToMany(mappedBy = "categories", cascade = CascadeType.REMOVE)
  private List&lt;Article&gt; articles;
  
  /**
   * Getters and setters
   * */
  }
  </code></pre>