gpt4 book ai didi

java - Spring 4 Attribute 'items' 必须是数组、Collection或Map

转载 作者:行者123 更新时间:2023-11-30 08:08:58 25 4
gpt4 key购买 nike

我在 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 my EL. If you create webapp project from Maven, you must declare isELIgnored="false" manually.

Thank you.

关于java - Spring 4 Attribute 'items' 必须是数组、Collection或Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32805369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com