teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

説明的にはこっちか

2018/03/14 11:06

投稿

退会済みユーザー
answer CHANGED
@@ -31,7 +31,7 @@
31
31
 
32
32
 
33
33
  ## 追記
34
- ちなみに、古いバージョンの commons-fileupload/commons-io のコピーため以下の用にコードを挟む必要があります。
34
+ ちなみに、古いバージョンの commons-fileupload/commons-io のコピーで依存関係をあいまいにするため以下のコードに変換する必要があります。
35
35
 
36
36
  ```
37
37
  import org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext;

2

古いやり方を追記

2018/03/14 11:06

投稿

退会済みユーザー
answer CHANGED
@@ -27,4 +27,15 @@
27
27
  String fieldValue = item.getString();
28
28
  parameter.put(fieldName,fieldValue);
29
29
  }
30
+ ```
31
+
32
+
33
+ ## 追記
34
+ ちなみに、古いバージョンの commons-fileupload/commons-io のコピーのため以下の用にコードを挟む必要があります。
35
+
36
+ ```
37
+ import org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext;
38
+ // 中略
39
+ ServletRequestContext rc = new ServletRequestContext(/* HttpServletRequest */ request);
40
+ List<FileItem> items = upload.parseRequest(rc);
30
41
  ```

1

説明文 form タグ

2018/03/14 11:04

投稿

退会済みユーザー
answer CHANGED
@@ -5,7 +5,7 @@
5
5
  Map<String,String> parameter = new HashMap();
6
6
  // https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/tomcat/util/http/fileupload/FileItem.html
7
7
  // isFormField : Determines whether or not a FileItem instance represents a simple form field.
8
- // isFormField : (意訳)<form type="method"> 送信時の <input type="file"> は false , それ以外は true
8
+ // isFormField : (意訳)<form method="post" ... > 送信時の <input type="file"> は false , それ以外は true
9
9
  if (!item.isFormField()){
10
10
  //PATHを含むファイル名を取得
11
11
  String fileName = item.getName();