@Provider public class FormDataFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { if (requestContext instanceof ContainerRequest) { ContainerRequest request = (ContainerRequest) requestContext; if ( requestContext.hasEntity() && MediaTypes.typeEqual(MediaType.APPLICATION_FORM_URLENCODED_TYPE,request.getMediaType())) { request.bufferEntity(); Form f = request.readEntity(Form.class); } } } }
目前找到的最好的答案。ide
以後就很簡單了。
value = f.asMap().get("key").get(0)