Teach you how to use WEBWORK to upload files

  
                

Everyone knows that webwork is simple, flexible and powerful. It is a standard Command pattern framework implementation, and completely separate from the web layer, dedicated to componentization and code reuse of the J2EE Web framework, but you don't know its other A good role, that is, you can also use WEBWORK to achieve file upload, the following will tell you how to use WEBWORK to achieve file upload method.

Webwork data binding using ognl is a very useful function , can avoid the cumbersome call request.getParameter, object setter, do not need any redundant configuration files, plus the function of the converter, we can use a business object, from the front desk to the background, no longer need to consider String Conversion, no DTO, no need for FormBean.

The ability to upload common files on web applications is also done with data binding, so it's perfect: action no longer needs to know any web information. Need to operate on a specific Object, call getObject, you need to operate on the file uploaded by the user, call getFile.

Before webwork 2.1.5, there was a detailed introduction to this problem. After 2.1.5, this interceptor was added to the official release version: com.opensymphony.webwork.interceptor.FileUploadInterceptor

our Action:

Code

we can see that this Action is quite simple, as long as the definition of a File type of property and setter, we can use the File object to any things are a

page and ordinary upload page is no different:

Code

Note that the field names and attributes of the same name Action on it, and the rest The thing is to configure the interceptor: Previous page12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved