-
-
Notifications
You must be signed in to change notification settings - Fork 202
Description
Given ajax POST like this:
$.ajax({
url: 'mypost',
method: 'post',
data: {ids: [1,2,3], key: someKey}), .....
});
How is supposed to parse the POST form and get the values using MVC?
I have a MVC method like this:
@POST @Path("/mypost")
public Result myPost(MyForm form) { .... }
where
class MyForm {
private List<Integer> ids;
private int key;
/* getters and setters ommited */
...
/* Here I've tried various constructors as described in docs, with no success */
}
for such a simple use case, jooby require me to send form this way:
ids[1] = 1,
ids[2] = 2,
etc...
but jquery sends it like this:
ids[] = 1,
ids[] = 2,
etc ....
and the error output is :
org.jooby.Err: Bad Request(400): Failed to parse parameter 'form' to 'com.myapp.models.MyForm'
at org.jooby.internal.MutantImpl.to(MutantImpl.java:88)
at org.jooby.internal.MutantImpl.to(MutantImpl.java:76)
at org.jooby.internal.mvc.RequestParam.lambda$param$14(RequestParam.java:198)
at org.jooby.internal.mvc.RequestParam.value(RequestParam.java:163)
at org.jooby.internal.mvc.MvcHandler.invoke(MvcHandler.java:72)
at org.jooby.internal.mvc.MvcHandler.handle(MvcHandler.java:53)
at org.jooby.Route$Handler.handle(Route.java:1717)
at org.jooby.internal.RouteImpl.handle(RouteImpl.java:113)
at org.jooby.internal.RouteChain.next(RouteChain.java:70)
at org.jooby.Route$Chain.next(Route.java:2106)
at org.jooby.Route$Before.handle(Route.java:1867)
at org.jooby.internal.RouteImpl.handle(RouteImpl.java:113)
at org.jooby.internal.RouteChain.next(RouteChain.java:70)
at org.jooby.Route$Chain.next(Route.java:2106)
at org.jooby.internal.HttpHandlerImpl.handle(HttpHandlerImpl.java:306)
at org.jooby.internal.netty.NettyHandler.channelRead0(NettyHandler.java:92)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:39)
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:364)
at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
.....
I'm using jooby 1.0.1.