Get post data from ByteArrayResource

326 Views Asked by At

I send data over post request to path which mount to:

public class AJAXPostPort extends ByteArrayResource implements IResource {
    ...
    @Override
    protected byte[] getData(Attributes attributes) {
        attributes.getRequest().getPostParameters(); <- EMPTY
        ...
    }
    ...
}

and can't get it :(. Request from client side is correct and catching from PHP.

Could you help me? how to catch post request from wicket module?

1

There are 1 best solutions below

0
On

It was easy:

@Override
protected byte[] getData(Attributes attributes) {

    HttpServletRequest request; 
    request = (HttpServletRequest)attributes.getRequest().getContainerRequest();
    String data=null;
    try {
        data = IOUtils.toString( req.getInputStream()); <- GET REAL POST DATA
    } catch ( IOException e ) {
        e.printStackTrace();
    }
    ...
}