i cannot get request body from Javalin's context
object
like context.formParam
,context.body()
,context.bodyAsClass()
i've tried like this, and i can get
request body, i use HttpServletRequest
directly to get
request body
public void addPerson(Context ctx){
Map<String, Object> map = new HashMap<>();
try {
String name = ctx.req.getParameter("person_name");
String address = ctx.req.getParameter("person_address");
personList.add(new Person(name,address));
map.put("status",200);
map.put("data","Success ");
ctx.json(map);
}catch (Exception ex){
map.put("status",500);
map.put("data","Fail");
ctx.status(500).json(map);
}
}
if i change ctx.req.getParameter
to ctx.formBody
there will be error message in server's log
Exception occurred while servicing http-request
java.lang.NoSuchMethodError: kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)[B
at io.javalin.http.CachedRequestWrapper$cachedBytes$2.invoke(CachedRequestWrapper.kt:21) ~[javalin-3.0.0.jar:na]
at io.javalin.http.CachedRequestWrapper$cachedBytes$2.invoke(CachedRequestWrapper.kt:16) ~[javalin-3.0.0.jar:na]
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) ~[kotlin-stdlib-1.2.71.jar:1.2.71-release-64 (1.2.71)]
at io.javalin.http.CachedRequestWrapper.getCachedBytes(CachedRequestWrapper.kt) ~[javalin-3.0.0.jar:na]
at io.javalin.http.CachedRequestWrapper.getInputStream(CachedRequestWrapper.kt:31) ~[javalin-3.0.0.jar:na]
at io.javalin.http.Context.bodyAsBytes(Context.kt:118) ~[javalin-3.0.0.jar:na]
at io.javalin.http.Context.body(Context.kt:108) ~[javalin-3.0.0.jar:na]
at...