java - spring 4 controller @RequestBody parameter -
i have following situation
public class mycustomform { private mycustomtype a; private mycustomtype b; } @restcontroller public class acontroller { @requestmapping(...) public void mymethod(@requestbody mycustomform form){ ... } } i want send in post request necessary data fill form. problem mycustomtype complex data type , cannot deserialized json.
the first thing tried write propertyeditor spring know how make deserialization string. solution works if use else beside @requestbody (it works @pathvariable example).
i made research , reason why @requestbody not working because annotation generates proxy uses own deserialization rules. rules not interfere custom propertyeditors.
the next thing tried use custom converter. solution still didn't solved issue.
any other ideas?
i understood newest version of jackson (version 2) know custom converters or propertyeditors updating jackson mapper not solution in case.
you can use @jsondeserialize mycustomtype classes like
public class mycustomform { @jsondeserialize(using = mycustomtypedeserializer.class) private mycustomtype a; @jsondeserialize(using = mycustomtypedeserializer.class) private mycustomtype b; } some references:
Comments
Post a Comment