Code: Select all
public void registerTask(@RequestBody MyRequestDto myRequestDto)
updated MyRequestDto class:
private final String existing1;
private final String existing2;
private final NewParam myNewparam; // this is the new param that is added
< /code>
Die Initialisierung erfolgt durch Konstruktor: < /p>
public MyRequestDto(String existing1, String existing2, NewParam myNewparam){
this.existing1 = existing1;
this.existing2 = existing2;
this.myNewparam = myNewparam;
}
< /code>
Dies ist die neue Param -Klassendefinition: < /p>
public class NewParam {
private final String name;
public NewParam(String name) {
this.name = name;
}
public String getName() {
return name;
}
[*] Wenn der Newparam < /code> nicht zum Anforderungskörper hinzugefügt wird. Ergebnis- 201 wird zurückgegeben
[*] Wenn der NewParam hinzugefügt wird, der Wert jedoch als NULL festgelegt wird. Ergebnis-201 wird zurückgegeben.
Code: Select all
{
"existing1": "test1",
"existing2": "test2",
"myNewparam": null
}
Beispiel:
{
"existing1": "test1",
"existing2": "test2",
"myNewparam": {
"name": "theme"
}
}
< /code>
< /li>
< /ol>
Hinweis: Die Integrationstests fehlschlagen ebenfalls. Während der Debugie der Integrationstests wird die Steuerung nicht zu Controller wird und nur einen Fehler als 400 schlechte Anfrage erhalten.