Let's assume there's a following Java-file, Foo.java:
public class Foo {
private String first;
private String second;
private String third;
public Foo(){
}
public Foo(String first, String second, String third){
this.first = first;
this.second = second;
this.third = third;
}
public String getFirst(){
return first;
}
public String getSecond(){
return second;
}
public String getThird(){
return third;
}
public void setFirst(String first){
this.first = first;
}
public void setSecond(String second){
this.second = second;
}
public void setThird(String third){
this.third = third;
}
}
Then there's another file, RESTcontroller.java:
import Bar;
import Foo;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/rest")
public class RESTController {
@RequestMapping(path = "/getFoo", method = RequestMethod.GET)
public void getFoo(Foo foo, HttpServletResponse response) {
Bar bar = Bar.getBar(foo)
...
}
}
Then in third file, http.js the 'getFoo' endpoint is called:
class Http {
getFoo(url, first, third) {
return `${url}getFoo?first=${first}&third=${third}`;
}
}
So, the question is, how the query parameters are used to construct the Foo parameter, when the second parameter needed in the Foo-constructor is missing? Which of the two constructors is used and at which point? Does this have something to do with Spring-framework? The example codes here are a version of code that has been proven to function.