如何使控制器的动作方法包含两个不同的bodyparser?例如,
@BodyParser.Of(BodyParser.Json.class)
@BodyParser.Of(BodyParser.FormUrlEncoded.class)
public static Result register() {
RequestBody body = request().body();
JsonNode node = body.asJson();
Map<String, String[]> map = body.asFormUrlEncoded();
if(node != null) {
return ok("Got: " + node);
} else if (map != null) {
return ok("Got: " + map);
} else {
return badRequest("Expecting application/json request body");
}
}