I try do POST some data to a Wicket WebPage. This works fine if the data is in a form. However, I want to post the data with jQuery's ajax-post. I am unable to get this data in my Page-constructor.
This is my jquery command:
$.ajax({
type: "post",
cache: false,
url: "http://localhost:8888/testjson",
data: JSON.stringify({"aap":"noot"),
contentType: 'application/json',
success: function(ydata){alert("aap");},
failure: function(errMsg) {alert(errMsg);},
contentType: false,
dataType: "json"
});
The /testjson is a mounted WebPage.
public TestJsonApiPage( PageParameters pp )
{
try
{
byte[] data = IOUtils.toByteArray( ( (ServletWebRequest) TestJsonApiPage.this.getRequest() ).getContainerRequest().getInputStream() );
}
catch ( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
This is the constructor. What I see happening is that the inputstream is empty. However, when debugging, I see the raw data that I posted in HttpServletRequest
in the newWebRequest
in my WicketApplication
tl;dr How to get the raw post data in Wicket Page?