google-code-export / nutz

Automatically exported from code.google.com/p/nutz
Apache License 2.0
1 stars 1 forks source link

关于上传文件正则表达式匹配可以支持的文件名报错的问题 #381

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
报错:
org.nutz.mvc.upload.UploadUnsupportedFileNameException: Unsupport file name 
'""' 

上传配置文件:
uploadFileContext : { 
        type : 'org.nutz.mvc.upload.UploadingContext',
        singleton : false, 
        args : [ { refer : 'tmpFilePool' } ], 
        fields : { 
            // 是否忽略空文件, 默认为 false
            ignoreNull : true,
            // 单个文件最大尺寸(大约的值,单位为字节,即 1048576 为 1M)
            maxFileSize : 1048576,
            // 正则表达式匹配可以支持的文件名
            nameFilter : '^(.+[.])(gif|jpg|png|bmp|jpeg)$' 
        } 
    },

详细说明:
如果把nameFilter : '^(.+[.])(gif|jpg|png|bmp|jpeg)$' 
这行去掉就不报错了,不知道问什么。

相关日志:

ActionInvokerImpl - Unsupport file name '""' 
org.nutz.mvc.upload.UploadUnsupportedFileNameException: Unsupport file name 
'""' 
    at org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:135)
    at org.nutz.mvc.upload.UploadAdaptor.adapt(UploadAdaptor.java:156)
    at org.nutz.mvc.invoker.ActionInvokerImpl.invoke(ActionInvokerImpl.java:236)
    at org.nutz.mvc.ActionInvoking.invoke(ActionInvoking.java:37)
    at org.nutz.mvc.NutMvcContent.handle(NutMvcContent.java:81)
    at org.nutz.mvc.NutServlet.service(NutServlet.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
    at java.lang.Thread.run(Thread.java:619)

Original issue reported on code.google.com by axh...@gmail.com on 15 Feb 2011 at 5:39

GoogleCodeExporter commented 9 years ago
补充:
这种错误是在提交表单而没选择上传文件的情况下。

Original comment by axh...@gmail.com on 15 Feb 2011 at 5:43

GoogleCodeExporter commented 9 years ago

Original comment by zozoh...@gmail.com on 16 Feb 2011 at 9:41

GoogleCodeExporter commented 9 years ago
Fixed in r1849

Original comment by zozoh...@gmail.com on 16 Feb 2011 at 9:44

GoogleCodeExporter commented 9 years ago
Fix again in r1883 真正地fix掉.

Original comment by wendal1985@gmail.com on 27 Feb 2011 at 1:40