您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> struts2的fileupload上传提示错误但文件上传成功

struts2的fileupload上传提示错误但文件上传成功

来源:网络整理     时间:2016/8/5 20:51:50     关键词:

关于网友提出的“ struts2的fileupload上传提示错误但文件上传成功”问题疑问,本网通过在网上对“ struts2的fileupload上传提示错误但文件上传成功”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: struts2的fileupload上传提示错误但文件上传成功
描述:

上传文件时提示
08:55:34,968 ERROR [struts2.interceptor.FileUploadInterceptor] Content-Type not allowed: file "111.txt" "upload_382792d6_12ca124d68c__8000_00000004.tmp" text/plain
但是文件却上传成功了,就是说sturts.xml的限制文件类型失败,文件还是上传了.

  

512000 

image/jpeg,image/gif
  
  
action文件
public String admin_wine_add() throws Exception
{
Date date = new Date();     
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String imagetype=fileFileName.substring(fileFileName.indexOf("."));//后缀名
FileOutputStream fos=new FileOutputStream("c:/upload"+sdf.format(date)+imagetype); 
        FileInputStream fis=new FileInputStream(file); 
        byte[] buffer=new byte[1024]; 
        int len=0; 
        while((len=fis.read(buffer))>0){ 
            fos.write(buffer, 0, len); 
        } 
        return "success"; 
}
还有个小问题:怎么别人的return SUCCESS;可以的
我也这样写不可以的?


解决方案1:

return "success"; 
是struts2 默认的一个返回操作,你要在xml文件返回中配置的


以上介绍了“ struts2的fileupload上传提示错误但文件上传成功”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3129413.html

相关图片

相关文章