RESTlet: How to process multipart/form-data requests?

前端 未结 3 1192
青春惊慌失措
青春惊慌失措 2020-12-18 11:38

How do you catch incoming @Post variables when it is a multipart/form-data request?

For a regular Post request I would do:

@Post
public void postExam         


        
3条回答
  •  隐瞒了意图╮
    2020-12-18 12:08

    to pack it on one line, in you Restlet Resource class :

    Iterator it = new RestletFileUpload(new DiskFileItemFactory()).parseRequest(getRequest()).iterator();

    Then in your loop through your items, you can test whether they are or not fileItems with the method: isFormField().

    Testing if a fileItem is a formField... makes sens ? ;)
    but it works.

    Good luck.

提交回复
热议问题