ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美亚男人的天堂,亚洲视频在线视频,亚洲男女毛片无遮挡http://www.aygfsteel.com/leekiang/category/25298.htmlMDA/MDD/TDD/DDD/DDDDDDDzh-cnThu, 04 Feb 2010 14:54:54 GMTThu, 04 Feb 2010 14:54:54 GMT60多文件上ä¼?/title><link>http://www.aygfsteel.com/leekiang/archive/2010/02/02/311732.html</link><dc:creator>leekiang</dc:creator><author>leekiang</author><pubDate>Tue, 02 Feb 2010 14:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/leekiang/archive/2010/02/02/311732.html</guid><wfw:comment>http://www.aygfsteel.com/leekiang/comments/311732.html</wfw:comment><comments>http://www.aygfsteel.com/leekiang/archive/2010/02/02/311732.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/leekiang/comments/commentRss/311732.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/leekiang/services/trackbacks/311732.html</trackback:ping><description><![CDATA[ <a target="_blank" >jquery-transmit</a>:<br />jQuery Multi-file Uploader with Flash<img src ="http://www.aygfsteel.com/leekiang/aggbug/311732.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/leekiang/" target="_blank">leekiang</a> 2010-02-02 22:57 <a href="http://www.aygfsteel.com/leekiang/archive/2010/02/02/311732.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>commons-fileupload 1.2发布时的官方声明http://www.aygfsteel.com/leekiang/archive/2008/09/27/231469.htmlleekiangleekiangSat, 27 Sep 2008 04:34:00 GMThttp://www.aygfsteel.com/leekiang/archive/2008/09/27/231469.htmlhttp://www.aygfsteel.com/leekiang/comments/231469.htmlhttp://www.aygfsteel.com/leekiang/archive/2008/09/27/231469.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/231469.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/231469.htmlCompared to the previous version 1.1.1, the following notable changes have been made:
    * A streaming API has been added. The streaming API allows to handle arbitrarily large files without intermediary files while still keeping an extremely low memory profile.
    * The presence of a content-length header is no longer required.
    * Added support for progress listeners.
    * Added support for header continuation lines.
    * Added support for limiting the actual file size, as opposed to the request size.



leekiang 2008-09-27 12:34 发表评论
]]>
hibernate处理oracle大字ŒD?/title><link>http://www.aygfsteel.com/leekiang/archive/2008/09/24/230867.html</link><dc:creator>leekiang</dc:creator><author>leekiang</author><pubDate>Wed, 24 Sep 2008 06:01:00 GMT</pubDate><guid>http://www.aygfsteel.com/leekiang/archive/2008/09/24/230867.html</guid><wfw:comment>http://www.aygfsteel.com/leekiang/comments/230867.html</wfw:comment><comments>http://www.aygfsteel.com/leekiang/archive/2008/09/24/230867.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/leekiang/comments/commentRss/230867.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/leekiang/services/trackbacks/230867.html</trackback:ping><description><![CDATA[1,以下是一些零¼„Žçš„记录åQŒä¸å…¨ã€?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">字段为java.sql.Blob¾cÕdž‹</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">Fj fj </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Fj();<br />fj.setAttblob(Hibernate.createBlob(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]));</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">用empty_blob()替换?</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">session.save(fj);<br />session.flush();<br />session.refresh(fj, LockMode.UPGRADE);<br />org.hibernate.blob.SerializableBlob sb </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"><br />(org.hibernate.blob.SerializableBlob) fj.getAttblob();<br />oracle.sql.BLOB blob </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (oracle.sql.BLOB) sb.getWrappedBlob();<br />OutputStream os </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> blob.getBinaryOutputStream();<br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">------</span></div><br />2,用jdbcè¯Õd–CLOB<br />http://hi.baidu.com/xh28025/blog/item/f61c2df1ef8130c47831aa70.html<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">String description </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);"><br />   query </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">select picstr from clobtest_table where id = '001'</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> con.prepareStatement(query);<br />ResultSet result </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pstmt.executeQuery();<br /></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(result.next()){<br />   oracle.jdbc.driver.OracleResultSet ors </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"><br />   (oracle.jdbc.driver.OracleResultSet)result;<br />   oracle.sql.CLOB clobtmp </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (oracle.sql.CLOB) ors.getClob(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br /><br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(clobtmp</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);"> clobtmp.length()</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">){<br />   System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">======CLOB对象为空 </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />   description </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">;<br />   }</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">{<br />   description</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">clobtmp.getSubString((</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">)clobtmp.length());//ä»?å¼€å§?<br />   System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">======字符串åŞ式Â?/span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">description);<br />   }<br />}</span></div><br /><br /><img src ="http://www.aygfsteel.com/leekiang/aggbug/230867.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/leekiang/" target="_blank">leekiang</a> 2008-09-24 14:01 <a href="http://www.aygfsteel.com/leekiang/archive/2008/09/24/230867.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用commons fileupload的零¼„Žç¬”è®?/title><link>http://www.aygfsteel.com/leekiang/archive/2007/08/27/139844.html</link><dc:creator>leekiang</dc:creator><author>leekiang</author><pubDate>Mon, 27 Aug 2007 03:58:00 GMT</pubDate><guid>http://www.aygfsteel.com/leekiang/archive/2007/08/27/139844.html</guid><wfw:comment>http://www.aygfsteel.com/leekiang/comments/139844.html</wfw:comment><comments>http://www.aygfsteel.com/leekiang/archive/2007/08/27/139844.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.aygfsteel.com/leekiang/comments/commentRss/139844.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/leekiang/services/trackbacks/139844.html</trackback:ping><description><![CDATA[我对表单上传的理è§?可能有误):<br /> <form action="" method="post" enctype="multipart/form-data"><br /> 最大上ä¼?G.<br /><a target="_blank" >通过 http 协议上传文äšg(rfc1867协议概述åQŒjsp 应用举例åQŒå®¢æˆïL«¯å‘送内å®ÒŽž„é€?</a><br /> 服务器接收到上传的流åQŒè‡ªå·±å…¶å®žæ˜¯ä¸ä½œä»ÖM½•处理的,那个request˜q˜æ˜¯åŽŸè£…çš?谁来处理˜q™ä¸ªrequestå‘?ä¸€èˆ¬é‡‡ç”¨ç¬¬ä¸‰æ–¹çš„å·¥å…øP¼Œ˜q™é‡Œä»¥commons fileuploadä¸ÞZ¾‹.<br /> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">DiskFileItemFactory factory </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> DiskFileItemFactory();<br />factory.setSizeThreshold(</span><span style="color: rgb(0, 0, 0);">4096</span><span style="color: rgb(0, 0, 0);">);</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 讄¡½®¾~“冲,˜q™ä¸ªå€¼å†³å®šäº†æ˜¯fileinputstream˜q˜æ˜¯bytearrayinputstream</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">factory.setRepository(new File(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">d:\\temp</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">讄¡½®ä¸´æ—¶å­˜æ”¾ç›®å½•,默认是new File(System.getProperty("java.io.tmpdir"))</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">ServletFileUpload sfu </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ServletFileUpload(factory);<br />sfu.setSizeMax(</span><span style="color: rgb(0, 0, 0);">100</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">1024</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">1024</span><span style="color: rgb(0, 0, 0);">);</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">100M</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">List items </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> sfu.parseRequest(request);</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">传入的这个request˜q˜æ˜¯åŽŸè£…çš?/span></div> 见上面的代码åQŒcommons fielupload通过ServletFileUpload¾cȝš„<span style="color: rgb(0, 0, 0);"><font color="#0000ff">parseRequest(request)<font color="#000000">æ–ÒŽ³•处理˜q™ä¸ªåŽŸå§‹‹¹ã€‚è€?/font></font></span>ServletFileUpload<span style="color: rgb(0, 0, 0);"><font color="#0000ff"><font color="#000000">又会调用其爷çˆïL±»FileUploadBaseçš„parseRequest(request)æ–ÒŽ³•åQŒç„¶åŽåˆä¼šè°ƒreturn parseRequest(new ServletRequestContext(request)),代码如下<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />            FileItemIterator iter </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getItemIterator(ctx);<br />            List items </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ArrayList();<br />            FileItemFactory fac </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getFileItemFactory();<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (fac </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">) {<br />                </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> NullPointerException(<br />                    </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">No FileItemFactory has been set.</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />            }<br />            </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> (iter.hasNext()) {<br />                FileItemStream item </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> iter.next();<br />                FileItem fileItem </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> fac.createItem(item.getFieldName(),<br />                        item.getContentType(), item.isFormField(),<br />                        item.getName());<br />                </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />                    Streams.copy(item.openStream(), fileItem.getOutputStream(),<br />                            </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br />                } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (FileUploadIOException e) {<br />                    </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> (FileUploadException) e.getCause();<br />                } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (IOException e) {<br />                    </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> IOFileUploadException(//报错¾lå¸¸åœ¨è¿™é‡?br />                            </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Processing of </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> MULTIPART_FORM_DATA<br />                            </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> request failed. </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> e.getMessage(), e);<br />                }<br />                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (fileItem </span><span style="color: rgb(0, 0, 255);">instanceof</span><span style="color: rgb(0, 0, 0);"> FileItemHeadersSupport) {<br />                    </span><span style="color: rgb(0, 0, 255);">final</span><span style="color: rgb(0, 0, 0);"> FileItemHeaders fih </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> item.getHeaders();<br />                    ((FileItemHeadersSupport) fileItem).setHeaders(fih);<br />                }<br />                items.add(fileItem);<br />            }<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> items;<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (FileUploadIOException e) {<br />            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> (FileUploadException) e.getCause();<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (IOException e) {<br />            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileUploadException(e.getMessage(), e);<br />        }<br />    </span></div><br /> ˜q™é‡Œæ³¨æ„,<font color="#0000ff">上传çš?lt;input type=file</font></font></font></span><font color="#0000ff">>标记一定要有name,如果没有åQŒcommons fielupload不作处理</font>ã€?br /> commons fielupload会把上传的文件以‹¹çš„æ–¹å¼å†™å…¥åˆ°tempæ–‡äšgå¤?临时文äšg夹可以自å·Þp®¾å®šï¼Œå¦‚果不手动设¾|®ï¼Œåˆ™æ˜¯Servlet容器为web应用分配的äÍæ—¶ç›®å½?tomcat可能ž®±æ˜¯<font color="#ff0000">%TOMCAT_HOME%\temp</font>åQŒæˆ‘用weblogicæ—Óž¼Œæ˜?font color="#ff0000">C:\DOCUME~1\yourname\LOCALS~1\Temp\</font>。这些äÍ时文件以"upload"å¼€å¤ß_¼Œæ ¼å¼æ˜?tmp,例如<font color="#ff0000">"upload_47fdc3_11c9eb678b0__8000_00000043.tmp"</font><br /> 在上传过½E‹ä¸­commons fielupload才知道上传的文äšg的大ž®ï¼Œå¦‚æžœä½ å®šä¹‰å…è®¸çš„æœ€å¤§é™„ä»¶äØ“100MåQŒç„¶åŽä½ ä¸Šä¼ ä¸€ä¸?00M的文ä»?那么只有实际传输äº?00M以后åQŒcommons fielupload才知道超˜q‡äº†åQŒç„¶åŽæŠ›å‡ÞZ¸€ä¸ªå¼‚å¸?<font color="#ff0000">org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException</font>)ã€?br /> commons fielupload处理完了以后(处理˜q‡ç¨‹å…¨åœ¨<span style="color: rgb(0, 0, 0);"><font color="#0000ff">parseRequest(request)</font>æ–ÒŽ³•é‡?/span>)åQŒè¿”回一个List,里面的每一™å¹å·²è¢«å°è£…䨓FileItem,你通过<font color="#0000ff">fileItem.isFormField()</font>判断出是普通的表单属性呢åQŒè¿˜æ˜¯ä¸€ä¸ªæ–‡ä»Óž¼Œå¦‚果是文ä»Óž¼Œä½ å¯ä»¥ä»Ž<font color="#0000ff">fileItem.getInputStream()</font>获得输入‹¹ï¼Œ˜q™ä¸ªè¾“å…¥‹¹å…¶å®žæ˜¯ä¸€ä¸ªFileInputStream.当然åQŒå¦‚果文件很ž®ï¼Œåˆ™æ˜¯ByteArrayInputStream.那么如何区分åQŸè¿™ä¸¤è€…的区别是由<font color="#0000ff">factory.setSizeThreshold(4096)</font>¼‹®å®šçš„。大äº?K,为FileInputStream,ž®äºŽ4K为ByteArrayInputStream<br /><br />˜q™æ ·ž®±å¯ä»¥è§£é‡Šstruts用ActionForm的方式处理上传附件的一些问题了åQŒstruts接收到enctype="multipart/form-data"çš„postè¯äh±‚后,会看那个对应的action有没有配¾|®actionformåQŒå¦‚果配¾|®äº†åQŒå°±ä¼šä½œä¸€äº›å¤„理,所以你在action里得到的request已经不是一个普通的request了,而是一个被ž®è£…˜q‡çš„request。如果想得到原始的requeståQŒå°±ä¸è¦struts-config.xml里给action¾c»é…¾|®actionform<br /><br />tempDir指定的目录中可能会随着旉™—´æŽ¨ç§»å‡ºçŽ°å¾ˆå¤šåŽç¼€ä¸?tmp"的垃圾文ä»Óž¼Œcommons-fileupload1.2提供了一个不错的解决æ–ÒŽ³•åQŒå°±æ˜¯æŠŠä¸‹é¢çš„代码加入到web.xml中即可ã€?br /><listener><br /><listener-class><br />org.apache.commons.fileupload.servlet.FileCleanerCleanup<br /></listener-class><br /></listener> <br />来源:<a target="_blank" >http://fratemity1314.spaces.live.com/Blog/cns!E3BCC13A1E72BB4F!222.entry</a><br /><br /><span id="wmqeeuq" class="tpc_content">Q:I'm using FileUpload in an Action, but it's not working. Why? <br /><br />A:Struts recognises multipart requests, and parses them automatically, presenting the request parameters to your code in the same manner as if they were regular request parameters. Since struts has already processed the request, and made it available in your form bean, the input stream is no longer available for parsing, so attempting to do so with FileUpload will fail. <br /><br />Q:But I need to parse the request myself. How can I do that? <br /><br />A:Struts parses multipart a request as a part of the process of populating your form bean from that request. If, for some reason, you need to have full control over the multipart parsing, you can do so by configuring your action mapping without an associated form bean. (A better way of doing this, however, is to replace the default multipart handler with your own. See the struts documentation for details.) </span><br /><br /><br />1åQŒç›´æŽ¥ç”¨commons fileupload而不用strutsçš„ActionFormæ—?表单里的属性å€ég¸èƒ½ç”¨request.getParameter()获取了,而url里的queryString可以ã€?br />2,  获取form里的属性值的代码<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: rgb(0, 0, 0);"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                    String formname </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> fi.getFieldName();</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 获取form中的名字</span><span style="color: rgb(0, 128, 0);"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: rgb(0, 0, 0);">                    String formcontent </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> fi.getString();<br /><img id="Codehighlighter1_130_247_Open_Image" onclick="this.style.display='none'; Codehighlighter1_130_247_Open_Text.style.display='none'; Codehighlighter1_130_247_Closed_Image.style.display='inline'; Codehighlighter1_130_247_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_130_247_Closed_Image" style="display: none;" onclick="this.style.display='none'; Codehighlighter1_130_247_Closed_Text.style.display='none'; Codehighlighter1_130_247_Open_Image.style.display='inline'; Codehighlighter1_130_247_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />                    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (formname.equals(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">id</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)) </span><span id="Codehighlighter1_130_247_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);"><img src="http://www.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_130_247_Open_Text"><span style="color: rgb(0, 0, 0);">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                        id </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> formcontent;</span><span style="color: rgb(0, 0, 0);"><br /><img id="Codehighlighter1_284_349_Open_Image" onclick="this.style.display='none'; Codehighlighter1_284_349_Open_Text.style.display='none'; Codehighlighter1_284_349_Closed_Image.style.display='inline'; Codehighlighter1_284_349_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_284_349_Closed_Image" style="display: none;" onclick="this.style.display='none'; Codehighlighter1_284_349_Closed_Text.style.display='none'; Codehighlighter1_284_349_Open_Image.style.display='inline'; Codehighlighter1_284_349_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />                    }</span></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (formname.equals(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)) </span><span id="Codehighlighter1_284_349_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);"><img src="http://www.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_284_349_Open_Text"><span style="color: rgb(0, 0, 0);">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                        title </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> formcontent;<br /><img id="Codehighlighter1_389_463_Open_Image" onclick="this.style.display='none'; Codehighlighter1_389_463_Open_Text.style.display='none'; Codehighlighter1_389_463_Closed_Image.style.display='inline'; Codehighlighter1_389_463_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_389_463_Closed_Image" style="display: none;" onclick="this.style.display='none'; Codehighlighter1_389_463_Closed_Text.style.display='none'; Codehighlighter1_389_463_Open_Image.style.display='inline'; Codehighlighter1_389_463_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />                    }</span></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (formname.equals(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">memo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)) </span><span id="Codehighlighter1_499_561_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);"><img src="http://www.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_499_561_Open_Text"><span style="color: rgb(0, 0, 0);">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                        memo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> formcontent;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />                    }</span></span><span style="color: rgb(0, 0, 0);"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span></div><br />3, 表单里的file控äšgçš„name不能为空ã€?br />4åQŒä¸Šä¼ å¤§æ–‡äšg(190多M)时报异常<br />org.apache.commons.fileupload.FileUploadException:   Processing   of   multipart/form-data   request   failed.   EOF   after   reading   only:   "3567789 "   of:   "203323339 "   promised   bytes,   out  of   which   at   least:   "0 "   were   already   buffered<br />http://forums.bea.com/thread.jspa?threadID=200033356<br />http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=20060&start=0&tstart=0<br />http://thisisxy.blogcn.com/diary,204014352.shtml<br />http://www.80diy.com/home/20050527/17/4040711.html<br /><br />5åQ?br /><span lang="EN-US"><font face="Times New Roman" size="3">org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. Read timed out<br /></font></span><font size="3"><span style="font-family: 宋体;"></span><span lang="EN-US"><font face="Times New Roman">HTTP</font></span><span style="font-family: 宋体;">‹zÕdЍ­‘…时限制的时间太çŸ?</span></font><span><strong><span id="wmqeeuq" class="guitag1">HTTP Keep-Alive Timeout</span></strong></span><span style="font-size: 10.5pt; font-family: Arial;" lang="EN-US">.<br /><br />6,InputStream is =formFile.getInputStream() ;  //formFile是org.apache.struts.upload.FormFile<br />上传的文件小时这个输入流是java.io.ByteArrayInputStreamåQŒä¸Šä¼ æ¯”较大的文件时˜q™ä¸ªè¾“å…¥‹¹æ˜¯FileInputStream<br /><br />7,讄¡½®è¡¨å•里的上传路径为只è¯?br /><input type=file id="uploadfile" name="uploadfile" style="display: none;"><br /><input type=text id=tempfile readonly="true"><br /><input type=button <br />onClick="uploadfile.click();tempfile.value=uploadfile.value;" value="‹¹è§ˆ.."><br /><br />10,<br />http://eastpoint.javaeye.com/blog/99084<br />http://topic.csdn.net/u/20080131/13/649c57c7-204e-4bb6-9b09-49cca39f00b8.html<br />http://blog.niwota.com/nb/chenchuang?cat_self_id=291075<br /></span><img src ="http://www.aygfsteel.com/leekiang/aggbug/139844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/leekiang/" target="_blank">leekiang</a> 2007-08-27 11:58 <a href="http://www.aygfsteel.com/leekiang/archive/2007/08/27/139844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> Ö÷Õ¾Ö©Öë³ØÄ£°å£º <a href="http://" target="_blank">½ðÃÅÏØ</a>| <a href="http://" target="_blank">¸»´¨</a>| <a href="http://" target="_blank">ÏæÏçÊÐ</a>| <a href="http://" target="_blank">Áú´¨ÏØ</a>| <a href="http://" target="_blank">ÀË¿¨×ÓÏØ</a>| <a href="http://" target="_blank">¸ßÑôÏØ</a>| <a href="http://" target="_blank">°ÍÌÁÏØ</a>| <a href="http://" target="_blank">ׯÀËÏØ</a>| <a href="http://" target="_blank">»ÆæèÊÐ</a>| <a href="http://" target="_blank">ÃÜÔÆÏØ</a>| <a href="http://" target="_blank">ÄϽ§</a>| <a href="http://" target="_blank">ÑôÔ­ÏØ</a>| <a href="http://" target="_blank">¾®ÚêÏØ</a>| <a href="http://" target="_blank">ËÞǨÊÐ</a>| <a href="http://" target="_blank">°¢°Í¸ÂÆì</a>| <a href="http://" target="_blank">Îñ´¨</a>| <a href="http://" target="_blank">ÉêÔúÏØ</a>| <a href="http://" target="_blank">Íþº£ÊÐ</a>| <a href="http://" target="_blank">ËÕÄáÌØÓÒÆì</a>| <a href="http://" target="_blank">¸»´¨</a>| <a href="http://" target="_blank">¼òÑôÊÐ</a>| <a href="http://" target="_blank">ÏÉÓÎÏØ</a>| <a href="http://" target="_blank">À³ÑôÊÐ</a>| <a href="http://" target="_blank">ÌìË®ÊÐ</a>| <a href="http://" target="_blank">µ±ÐÛÏØ</a>| <a href="http://" target="_blank">ͨºÓÏØ</a>| <a href="http://" target="_blank">ÌÚ³åÏØ</a>| <a href="http://" target="_blank">Ëç·ÒºÓÊÐ</a>| <a href="http://" target="_blank">Çì³ÇÏØ</a>| <a href="http://" target="_blank">¿¦À®Ç߯ì</a>| <a href="http://" target="_blank">ÄÚ½­ÊÐ</a>| <a href="http://" target="_blank">ʯ¼ÒׯÊÐ</a>| <a href="http://" target="_blank">º×±ÚÊÐ</a>| <a href="http://" target="_blank">¶¨±ßÏØ</a>| <a href="http://" target="_blank">°²ÐÂÏØ</a>| <a href="http://" target="_blank">ÈÄÑôÏØ</a>| <a href="http://" target="_blank">³¤´ºÊÐ</a>| <a href="http://" target="_blank">ÕÄÆ½ÊÐ</a>| <a href="http://" target="_blank">ÒåÎÚÊÐ</a>| <a href="http://" target="_blank">ÁÙ°²ÊÐ</a>| <a href="http://" target="_blank">³çÀñÏØ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>