高层住宅地下室用途:Tapestry4集成Oracle InterMedia
来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 17:07:55
第一步:在web.xml配置interMedia的filter
第二步:定义自己的MultipartDecoderFilter
仿照tapestry的MultipartDecoderFilter,写自己的MultipartDecoderFilter(例如类名为org.MYMultipartDecoderFilter),自己写的filter和tapestry相比主要是判断request是否已被包装,如果被包装了就直接继续处理(见下列代码的if-else部分)
public void service(HttpServletRequest request,
HttpServletResponse response, ServletRequestServicer servicer)
throws IOException, ServletException ...{
String contentType = request.getContentType();
// contentType is occasionally null in testing. The browser tacks on additional
// information onto the contentType to indicate where the boundaries are in
// the stream.
boolean encoded = contentType != null
&& contentType.startsWith("multipart/form-data");
try ...{
//HttpServletRequest newRequest = encoded ? _decoder.decode(request) : request;
HttpServletRequest newRequest = null;
if (request instanceof HttpServletRequestWrapper) ...{
newRequest = request;
} else ...{
newRequest = encoded ? _decoder.decode(request) : request;
}
servicer.service(newRequest, response);
} finally ...{
if (encoded)
_decoder.cleanup();
// System.out.println("ttt");
}
}
在hivemodul中配置使用:
Identifies upload requests and passes them to the MultipartDecoder service for decoding.
第三步:开始处理
页面中注入属性:
html中使用表单的文件上传元素(input type="file" name="upload"/>)或upload组件
在页面类中即可得到interMedia类型的上传文件:
RequestGlobals obj = this.getRequestGlobals();
OrdMultipartWrapper obj1 = (OrdMultipartWrapper) obj.getRequest();
OrdHttpUploadFile[] files = obj1 .getFileParameterValues("upload");