The bean property is not readable or has the wrong method of getting

So, I have the task of writing a simple web application for registry paths. Using Spring MVC. Therefore, I have a class "Route", where I want to save the start point, the end point and a list of intermediate points. But I do not understand how to put values ​​into a list from jsp (for example, using jstl). So I decided to parse the string.

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);
        }
    }
}

and follow the 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>

If necessary, I can publish the controller code. And I have an error:

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?

Can someone explain what I'm doing wrong?

+4
source share
2 answers

getter bean,

public String getForm() {
   return form;
}

setForm

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

public String getForm(){
    return form;
}

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

Source: https://habr.com/ru/post/1570032/


All Articles