public void scfile() throws IOException{
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
//上传文件路径
String fileName = request.getParameter("fielname");
System.out.println("filename=="+fileName);//ceshi.html
InputStream is = null;
FileOutputStream fs = null; DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
try {
//is = cform.getImportfile().getInputStream();
//创建文件
File inFile = new File(fileName);
is=new FileInputStream(inFile);
System.out.println("====");
BufferedReader br=new BufferedReader(new InputStreamReader(is));上面代码有什么问题,哪里错了
红色那行报文件路径[ERROR] ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'fielname' on 'class com.asideal.struts.hyym.action.HyymAction: Error setting expression 'fielname' with value '[Ljava.lang.String;@ae0ba7'
filename==ceshi.html
java.io.FileNotFoundException: ceshi.html (系统找不到指定的文件。)
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
//上传文件路径
String fileName = request.getParameter("fielname");
System.out.println("filename=="+fileName);//ceshi.html
InputStream is = null;
FileOutputStream fs = null; DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
try {
//is = cform.getImportfile().getInputStream();
//创建文件
File inFile = new File(fileName);
is=new FileInputStream(inFile);
System.out.println("====");
BufferedReader br=new BufferedReader(new InputStreamReader(is));上面代码有什么问题,哪里错了
红色那行报文件路径[ERROR] ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'fielname' on 'class com.asideal.struts.hyym.action.HyymAction: Error setting expression 'fielname' with value '[Ljava.lang.String;@ae0ba7'
filename==ceshi.html
java.io.FileNotFoundException: ceshi.html (系统找不到指定的文件。)
解决方案 »
- JAVA测试题
- 上传文件,运行出来为空
- 【保证结贴】两年java开发经验,需要懂多少东西?
- struts2.x和webwork有什么关系?
- 急~~~在线等,关于Tapestry初始化类的问题!!!!!
- SQL多条件查询出现的一个问题,在线~~~~~~~~~~~~~~~~~
- JAVA技术讨论的QQ群:13176388,欢迎大家加入
- 初学XML转Java源文件的问题,大家都来说两句,真诚给分!
- 一个sqlserver2000的查询问题在线等
- 成功通过Axis+Tomcat模拟一个银行存取款服务的请进
- 用软件原则最简单的解释:为什么struts2的插件用拦截器而没有用过滤器?
- xsl显示for循环累加问题
inFile = new File(fileName);
}
String fileName = request.getParameter("fielname");这个是文件路径还是文件名字???
你这样的实现方式就不对。哪有这样获取文件名的?
在不同os,不同浏览器,表单中,上传框的文本内容,通过request.getParameter("");获取的内容都不尽一样,有的是带路径的,有的却不是。所以,只能是,通过上传组件(你所使用的上传第三方jar),获取上传对象,从中获取文件名,size,类型等等信息。
FileInputStream fin = null;
FileOutputStream fout = null;
.....
fout = new FileOutputStream(new File(filename));