If I use @RequestParam
in my controllers, I can name a variable different from the param name, if I set "name" attribute.
public String showSomething(@RequestParam(name = "field_1") String firstField /*other params*/) {
return "viewName";
}
Can I name a variable different from the param name, if I use complex object?
ComplexObject.java
public class ComplexObject {
private String firstField; // I want the value of the "field_1" parameter to get here
private String secondField; // And "field_2" to get here
//getters, setters
}
SimpleController.java
@Controller
public class SimpleController {
public String showSomething(ComplexObject complexObject) {
return "viewName";
}
If possible, I would like to know how to do it.