Spring MVC: Complex object as parameter
<p>I started to learn spring boot and I'm faced with problems. I have following code:</p>

<pre><code>@RestController
public class UserController {

    @RequestMapping("/")
    public String getMessageInfo(Message message) {
        return "Id is " + message.getId() + ", message is " + message.getMessage() + ", parameter good is " + message.isGood();
    }
}
</code></pre>

<p>Class Message:</p>

<pre><code>public class Message {
    private String message;
    private int id;
    private boolean good;

    public Message() {}

    public Message(int id) {this.id = id;}

    public Message(String message) {this.message = message;}

    public Message(boolean good) {this.good = good;}

    public Message(String message, boolean good, int id) {
        this.message = message;
        this.good = good;
        this.id = id;
    }

    public String getMessage() {
        return message;
    }

    public int getId() {
        return id;
    }

    public boolean isGood() {
        return good;
    }
}
</code></pre>

<p>And when I try to do something like this: </p>

<pre><code>RestTemplate request = new RestTemplate();
String info = request.getForObject("http://localhost:8080/?id=4", String.class);
</code></pre>

<p>value of <code>id</code> is ignored. Same problem appears when I send request with boolean <code>good</code> parameter (for example <code>localhost:8080/?good=true</code>). It is called the default constructor instead of <code>Message(boolean)</code>/<code>Message(int)</code>. But when I do something like <code>localhost:8080/?message=1234</code> it isn't ignored. Can you explain me what is the problem? </p>

<p>And one more question: can I send instance of class <code>Message</code> to <code>getMessageInfo</code> in different way than <code>localhost:8080/?message=1234&amp;good=true&amp;id=145</code>? If I have more than 3 parameters? For example if class <code>Message</code> has 100 parameters?</p>