[英]play framework file upload
I'm trying to add file uploading handling in play framework app to existing form with text field. 我正在尝试将play framework应用程序中的文件上传处理添加到带有文本字段的现有表单中。 According to documentation, I need to use
asMultipartFormData()
or asRaw
method, however, it can not handle text input fields. 根据文档,我需要使用
asMultipartFormData()
或asRaw
方法,但是它不能处理文本输入字段。 Is it possible to use one controller for standart html form and file processing at the same time? 是否可以同时使用一个控制器处理标准HTML表单和文件?
Yes, it is possible, just simply handle file and text input separately. 是的,有可能,只需简单地分别处理文件和文本输入即可。 For instance:
例如:
public Result myControllerMethod(){
...
//handle input text here
Form<MyModel> myForm = formFactory.form(MyModel.class);
MyModel myModel = myForm.bindFromRequest().get();
...
//handle file
MultipartFormData<File> body = request().body().asMultipartFormData();
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.