问题在于您提交表单。Spring无法绑定命令的对象,因此它不提交表单,而是将您重定向到formView。
成功执行绑定后,您将看到以下消息:
No errors -> processing submit
要解决您的问题,您将需要向控制器注册一个CustomCollectionEditor。(请参阅此链接)。就像这样:
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception{ binder.registerCustomEditor(Set.class, "rules", new CustomCollectionEditor(Set.class) { protected Object convertElement(Object element) { String name = ""; if (element instanceof String) name = (String) element; return name != null ? new Rule(name) : null; } });}


