No. 2 ファイルのアップロードでの疑問
SAStrutsのチュートリアルより、ファイルのアップロード。
これも基本的には、Strutsの仕組み。
@Required(target = "upload") @Binding(bindingType = BindingType.NONE) public FormFile formFile; public String message; public ServletContext application; @Execute(input = "ipSearch.jsp") public String upload() { String path = application.getRealPath("/WEB-INF/work/" + formFile.getFileName()); try { OutputStream out = new BufferedOutputStream(new FileOutputStream( path)); try { out.write(formFile.getFileData(), 0, formFile.getFileSize()); } finally { out.close(); } } catch (IOException e) { throw new IORuntimeException(e); } message = MessageResourcesUtil.getMessageResources().getMessage( "messages.upload.complete", path); return "ipSearch.jsp"; }
わからなかったのは、チュートリアルでは、formFileを
@Binding(bindingType = BindingType.NONE) public FormFile formFile;
としていますが、@Bindingアノテーションをつけなければいけない理由がわかりませんでした。
はずすと、
WARN 2008-01-27 09:32:03,560 [http-8080-Processor24] test.action.IpAction$$EnhancedByS2AOP$$dc41c5のプロパティ(formFile)が見つからないので設定をスキップします
というログが吐かれます。
明日以降で考察しよう。