我在 Spring 4 中创建 Combobox 项时出现此错误。
java.lang.IllegalArgumentException: Attribute 'items' must be an array, a Collection or a Map
org.springframework.web.servlet.tags.form.AbstractMultiCheckedElementTag.writeTagContent(AbstractMultiCheckedElementTag.java:234)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
...
我有 POJO 类 Student
:
public class Student {
@Size(min=3, max=30)
private String firstName;
@Size(min=3, max=30)
private String lastName;
@NotEmpty
private String sex;
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Past @NotNull
private Date dob;
@Email @NotEmpty
private String email;
@NotEmpty
private String section;
@NotEmpty
private String country;
private boolean firstAttempt;
@NotEmpty
private List<String> subjects = new ArrayList<String>();
...
我在我的 Controller 中创建方法并用 @ModelAttribute
注释它
@ModelAttribute("sections")
public List<String> initializeSections() {
List<String> sections = new ArrayList<String>();
sections.add("Graduate");
sections.add("Post Graduate");
sections.add("Research");
return sections;
}
这是我的 JSP:
...
<div class="row">
<div class="form-group col-xs-12">
<label class="col-xs-3" for="section">Section</label>
<div class="col-xs-7">
<form:radiobuttons path="section" items="${sections}"/>
<div class="has-error">
<form:errors path="section" class="help-inline" />
</div>
</div>
</div>
</div>
...
当我运行时,我收到上面的错误消息。 如何解决?缺少什么?
最佳答案
Answer ✓
I missing one thing, i have to add this
isELIgnored="false"
, i found this according instruction from @JB Nizet to print out myEL
. If you create webapp project from Maven, you must declareisELIgnored="false"
manually.Thank you.
关于java - Spring 4 Attribute 'items' 必须是数组、Collection或Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32805369/