Jsp JSTL字符串与ArrayList元素比较

Jsp JSTL字符串与ArrayList元素比较,jsp,if-statement,arraylist,jstl,Jsp,If Statement,Arraylist,Jstl,使用此代码 <c:forEach var="row" varStatus="loop" items="${court.monday}"> <tr> <c:choose> <c:when test='${row eq "Free Court"}'> <td class="inner">${loop.index} is Bookable </td> </c:when> <c:otherwise> &l

使用此代码

  <c:forEach var="row" varStatus="loop" items="${court.monday}">
<tr>
<c:choose>
<c:when test='${row eq "Free Court"}'>
<td class="inner">${loop.index} is Bookable </td>
</c:when>
<c:otherwise>
<td class="inner">${row}</td>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
课程表是

public class MonaleenTTV1 implements Timetable {

    @Id
    @GeneratedValue
    private int id;

    @Size(min=5, max=10, message="Court must be between 5 and 10 characters",groups={PersistenceValidationGroup.class, FormValidationGroup.class})
    private String name;

    @NotNull
    //@Min(value = 1, message="Value must be 1 or greater")
    private int slots;

    private int startTime;

    private int endTime;

    private boolean enabled;

    @ElementCollection
    @CollectionTable (name = "monday", joinColumns=@JoinColumn(name="id"))
    List<String> monday;

    @ElementCollection
    @CollectionTable (name = "tuesday", joinColumns=@JoinColumn(name="id"))
    List<String> tuesday;

    @ElementCollection
    @CollectionTable (name = "wednesday", joinColumns=@JoinColumn(name="id"))
    List<String> wednesday;

    @ElementCollection
    @CollectionTable (name = "thursday", joinColumns=@JoinColumn(name="id"))
    List<String> thursday;

    @ElementCollection
    @CollectionTable (name = "friday", joinColumns=@JoinColumn(name="id"))
    List<String> friday;

    @ElementCollection
    @CollectionTable (name = "saturday", joinColumns=@JoinColumn(name="id"))
    List<String> saturday;

    @ElementCollection
    @CollectionTable (name = "sunday", joinColumns=@JoinColumn(name="id"))
    List<String> sunday;
公共类MonaleenTTV1实现时间表{
@身份证
@生成值
私有int-id;
@大小(最小值=5,最大值=10,message=“Court必须在5到10个字符之间”,groups={PersistenceValidationGroup.class,FormValidationGroup.class})
私有字符串名称;
@NotNull
//@最小值(值=1,消息=“值必须大于等于1”)
专用int插槽;
私人内部启动时间;
私有内部结束时间;
启用私有布尔值;
@元素集合
@CollectionTable(name=“monday”,joinColumns=@JoinColumn(name=“id”))
星期一上市;
@元素集合
@CollectionTable(name=“周二”,joinColumns=@JoinColumn(name=“id”))
星期二上市;
@元素集合
@CollectionTable(name=“周三”,joinColumns=@JoinColumn(name=“id”))
星期三上市;
@元素集合
@CollectionTable(name=“星期四”,joinColumns=@JoinColumn(name=“id”))
星期四上市;
@元素集合
@CollectionTable(name=“friday”,joinColumns=@JoinColumn(name=“id”))
星期五上市;
@元素集合
@CollectionTable(name=“saturday”,joinColumns=@JoinColumn(name=“id”))
星期六上市;
@元素集合
@CollectionTable(name=“sunday”,joinColumns=@JoinColumn(name=“id”))
星期日名单;

啊!我的代码没有问题。重新启动Tomcat使它工作起来了!:)

您向我们展示的代码不会导致问题。法庭是一个字符串,没有getMonday()方法。这是消息告诉您的。鉴于我们不知道您从何处以及如何获得court,我们无法提供帮助。court是一个时间表对象,包含7个字符串数组列表(court.monday是周一列表等)我已经更新了帖子以显示控制器和时间表部分类本质上,我可以循环浏览每个列表,并显示每个列表,没有问题,但我想将每个列表中的每个条目与某个值进行比较,并在某些情况下更改我的操作以显示列表项或不同的链接。请使用“==”而不是“eq”尝试一次星期一,我在法庭上审理了同样的问题
@RequestMapping(value = "/gotoCourt", method=RequestMethod.POST)
    public String chooseCourt(Model model, HttpServletRequest request){
        model.addAttribute("court", timetableService.getById(request.getParameter("courtID")));
        return "court";
    }
public class MonaleenTTV1 implements Timetable {

    @Id
    @GeneratedValue
    private int id;

    @Size(min=5, max=10, message="Court must be between 5 and 10 characters",groups={PersistenceValidationGroup.class, FormValidationGroup.class})
    private String name;

    @NotNull
    //@Min(value = 1, message="Value must be 1 or greater")
    private int slots;

    private int startTime;

    private int endTime;

    private boolean enabled;

    @ElementCollection
    @CollectionTable (name = "monday", joinColumns=@JoinColumn(name="id"))
    List<String> monday;

    @ElementCollection
    @CollectionTable (name = "tuesday", joinColumns=@JoinColumn(name="id"))
    List<String> tuesday;

    @ElementCollection
    @CollectionTable (name = "wednesday", joinColumns=@JoinColumn(name="id"))
    List<String> wednesday;

    @ElementCollection
    @CollectionTable (name = "thursday", joinColumns=@JoinColumn(name="id"))
    List<String> thursday;

    @ElementCollection
    @CollectionTable (name = "friday", joinColumns=@JoinColumn(name="id"))
    List<String> friday;

    @ElementCollection
    @CollectionTable (name = "saturday", joinColumns=@JoinColumn(name="id"))
    List<String> saturday;

    @ElementCollection
    @CollectionTable (name = "sunday", joinColumns=@JoinColumn(name="id"))
    List<String> sunday;