public interface Form extends MultiValueMap<String,String>
The form is modelled as a MultiValueMap, with extra methods for dealing with file uploads.
That is, uploaded files are not visible via the methods provided by MultiValueMap.
All instances of this type are immutable.
Calling any mutative method of MultiValueMap will result in an UnsupportedOperationException.
import ratpack.handling.Handler;
import ratpack.handling.Context;
import ratpack.form.Form;
import ratpack.form.UploadedFile;
public class FormHandler implements Handler {
public void handle(Context context) {
context.getByMethod().post(new Runnable() {
public void run() {
Form form = context.parse(Form.class);
UploadedFile file = form.file("someFile.txt");
String param = form.get("param");
List<String> multi = form.getAll("multi");
context.render("form uploaded!");
}
});
}
}
| Modifier and Type | Method and Description |
|---|---|
UploadedFile |
file(String name)
Return the first uploaded file with the given name.
|
MultiValueMap<String,UploadedFile> |
files()
Returns all of the uploaded files.
|
List<UploadedFile> |
files(String name)
Return all of the uploaded files with the given name.
|
clear, get, getAll, getAll, put, putAll, removecontainsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, size, values@Nullable UploadedFile file(String name)
name - The name of the uploaded file in the formnull if no file was uploaded by that nameList<UploadedFile> files(String name)
name - The name of the uploaded files in the formMultiValueMap<String,UploadedFile> files()