Bean 属性不可读或具有无效的 getter 方法

Bean property is not readable or has an invalid getter method

因此,我的任务是为注册表路由编写一个简单的 Web 应用程序。使用 Spring MVC。所以我有 class "Route",我想在其中保留起点、终点和中间点列表。但我不明白,如何将值放入 jsp 的列表(例如使用 jstl)。所以我决定解析一个字符串。

public class Route {
    private String start;
    private String finish;
    private String form;
    private List<String> list;

    public Route() {
    }

    public Route(String start, String finish, String route) {
        this.start = start;
        this.finish = finish;
        this.form = route;
        this.toList();
    }

    public Route(String start, String finish) {
        this.start = start;
        this.finish = finish;
        this.list = new ArrayList<>();
    }

    public void addTown(String town){
        list.add(town);
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getFinish() {
        return finish;
    }

    public void setFinish(String finish) {
        this.finish = finish;
    }

    public List<String> getRoute() {
        return list;
    }

    public void setFormRoute(String route) {
        this.form = route; 
        this.toList();
    }    

    private void toList()
    {
        String[] temp = form.split(",");
        for(String temp1 : temp) {
            list.add(temp1);
        }
    }
}

并遵循 JSP:

<h2><a href="find.htm">Найти существующий маршрут</a><br/><br/>
    Добавить маршрут</h2>
<h3> 
    <spring:nestedPath path="route">
        <form modelAttribute="routeAttribute" method="POST" action="${add}">
            Пункт отправления:
            <spring:bind path="start">
                <input type="text" name="${status.expression}" value="${status.value}">
            </spring:bind><br/><br/>                    
            Пункт прибытия:
            <spring:bind path="finish">
                <input type="text" name="${status.expression}" value="${status.value}">
            </spring:bind><br/><br/>
            Промежуточные пункты (через запятую):
            <spring:bind path="form">
                <input type="text" name="${status.expression}" value="${status.value}">
            </spring:bind><br/><br/>

            <input type="submit" value="Сохранить">
        </form>
    </spring:nestedPath>

如果需要,我可以 post 控制器代码。 我有一个错误:

Bean property 'form' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

谁能解释一下我做错了什么?

按照错误消息的指示将表单的 getter 方法添加到 bean

public String getForm() {
   return form;
}

setForm应该有对应的方法

public void setForm(String form) {
   this.form = form;
}

添加关注

public String getForm(){
    return form;
}

public void setForm(String form){
    this.form = form;
    this.toList();
}