您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > XFace单文件上传组件使用指南
XFace(X-UI已经更名为XFace)项目组-1-1/10/2020XFace单文件上传组件使用指南夏天2009-02-25(运行效果)XFace(X-UI已经更名为XFace)项目组-2-1/10/2020目录XFace单文件上传组件使用指南...................................................................................................1目的..................................................................................................................................................3特点..................................................................................................................................................3配置..................................................................................................................................................3Web.xml配置...........................................................................................................................3Tld配置....................................................................................................................................4引入jar.....................................................................................................................................4引入资源...................................................................................................................................5组件实现代码...................................................................................................................................5使用..................................................................................................................................................7JSP中组件的使用....................................................................................................................7Action中如何获取已经上传到文件内容...............................................................................7XFace(X-UI已经更名为XFace)项目组-3-1/10/2020目的实现文件上传时能实时的看到文件上传到进度。并能在各种浏览器中使用该组件。特点1、异步上传文件2、支持大文件的上传3、实时显示上传进度4、没有浏览器限制,支持各种浏览器5、该组件可以独立使用,与Layout和XFace都没有耦合度配置Web.xml配置确保在web.xml中有下面的配置servletservlet-nameJSONRPCServlet/servlet-nameservlet-classjcore.jsonrpc.servlet.JSONRPCServlet/servlet-classload-on-startup2/load-on-startup/servletservletservlet-nameCommonHttpServlet/servlet-nameservlet-classcom.yinhai.xui.servlet.CommonHttpServlet/servlet-class/servletservlet-mappingservlet-nameJSONRPCServlet/servlet-nameurl-pattern/JRPC/url-patternXFace(X-UI已经更名为XFace)项目组-4-1/10/2020/servlet-mappingservlet-mappingservlet-nameCommonHttpServlet/servlet-nameurl-pattern/CMHS/url-pattern/servlet-mappingTld配置首先在你的项目中使用的tld文件,例如:webapp\WEB-INF\struts-layout.tld文件中加入下面的配置:tagnamexfaceUpldfl/nametagclasscom.yinhai.upfile.XFaceUpLoadFile/tagclassbodycontentJSP/bodycontentattributenameid/namerequiredfalse/requiredrtexprvaluefalse/rtexprvalue/attributeattributenamewidth/namerequiredfalse/requiredrtexprvaluefalse/rtexprvalue/attributeattributenameheight/namerequiredfalse/requiredrtexprvaluefalse/rtexprvalue/attributeattributenameproperty/namerequiredfalse/requiredrtexprvaluefalse/rtexprvalue/attribute/tag引入jar在工程中引入最新的JSON-RPC.jar和XFaceUploadFile.jar。而JSON-RPC.jar可以从获得最新的jar包。XFace(X-UI已经更名为XFace)项目组-5-1/10/2020Json-rpc.jar中增加了对异步文件上传的支持。引入资源将sgflupld.swf文件拷贝到你的工程目录:webapp/skin/1/resource下组件实现代码该组件实现的代码如下所示(如果有特殊需求,可以执行扩展定制):packagecom.yinhai.upfile;importjava.io.IOException;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.jsp.JspException;importjavax.servlet.jsp.tagext.TagSupport;publicclassXFaceUpLoadFileextendsTagSupport{privateStringwidth=353;privateStringheight=193;privateStringproperty;publicvoidrelease(){width=353;height=193;property=id=null;super.release();}publicintdoStartTag()throwsJspException{StringBufferbuf=newStringBuffer();StringszCtxPath=((HttpServletRequest)pageContext.getRequest()).getContextPath();StringszSwf=szCtxPath+/resource/sgflupld.swf?name=+property+&ActionPath=/xuicore/JRPC?;StringszId=null==getId()?:id=\+getId()+\;buf.append(objectclassid=\clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\XFace(X-UI已经更名为XFace)项目组-6-1/10/2020codebase=\=10,0,0,0\width=\+width+\height=\+height+\+szId+align=\top\);buf.append(paramname=\allowScriptAccess\value=\sameDomain\/);buf.append(paramname=\allowFullScreen\value=\false\/);buf.append(paramname=\movie\value=\+szSwf+\/);buf.append(paramname=\loop\value=\false\/);buf.append(paramname=\menu\value=\false\/);buf.append(paramname=\quality\value=\best\/);buf.append(paramname=\wmode\value=\Transparent\/);buf.append(paramname=\bgcolor\value=\#ffffff\/);szId=null==getId()?:name=\+getId()+\;buf.append(embedsrc=\+szSwf+\loop=\false\menu=\false\quality=\best\wmode=\Transparent\bgcolor=\#ffffff\width=\+width+\height=\+height+\+szId+align=\top\allowScriptAccess=\sameDomain\allowFullScreen=\false\type=\application/x-shockwave-flash\pluginspage=\);buf.append(/object);try{pageContext
本文标题:XFace单文件上传组件使用指南
链接地址:https://www.777doc.com/doc-2868092 .html