社区
Web 开发
帖子详情
百分请教个common-fileupload的问题
xmadan
2006-07-27 05:02:45
使用fileupload
已导入包commons-fileupload-1.1.1.jar、commons-io-1.2.jar
结果读不到页面的file类型,请各位大侠帮忙,代码如下所示
代码一跑到就
while (iter.hasNext()) {
就跳出while
form的类型也有设
估计是包的问题,代码我从另一个项目来的,只改了点,另一个项目的可以
...全文
228
8
打赏
收藏
百分请教个common-fileupload的问题
使用fileupload 已导入包commons-fileupload-1.1.1.jar、commons-io-1.2.jar 结果读不到页面的file类型,请各位大侠帮忙,代码如下所示 代码一跑到就 while (iter.hasNext()) { 就跳出while form的类型也有设 估计是包的问题,代码我从另一个项目来的,只改了点,另一个项目的可以
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
xmadan
2006-08-02
打赏
举报
回复
分随便给了吧
xmadan
2006-08-02
打赏
举报
回复
问题已经自己解决了,action不引用form就没事了。
terry_yip
2006-07-31
打赏
举报
回复
你在while之前的代码都没错。错应该是页面上的问题,你的form和file为什么不用struts的标签呢?
xmadan
2006-07-31
打赏
举报
回复
没有人能解决吗?
ray_1981
2006-07-27
打赏
举报
回复
关注中!
mrdangdong
2006-07-27
打赏
举报
回复
关注,关注
xmadan
2006-07-27
打赏
举报
回复
action(略去部分):
public class ImportEdiAction
extends ActionTemplate {
public ActionForward importEdi(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
try {
String path = CommonUtil.UPLOAD_PATH;
DiskFileUpload upload = new DiskFileUpload();
upload.setRepositoryPath(path);
List list = upload.parseRequest(request);
Iterator iter = list.iterator();
while (iter.hasNext()) {
FileItem file = (FileItem) iter.next();
if (file != null) {
// 写入文件a.txt,你也可以从fileName中提取文件名:
String fileName = "upload"
+ String.valueOf(new Date().getTime()) +
".txt";
file.write(new File(path + fileName));
//读取并保存到数据库中
ImportService ser = ((ImportService)getService());
List result = ser.importEdi(path + fileName,imAllFlag);
if(result.size() != 0){
//审核不通过
request.setAttribute("import.error",result);
}
//删除临时文件
file.delete();
}
}
}catch (Exception e) {
e.printStackTrace();
}
return mapping.findForward(this.IMPORT_PAGE);
}
}
xmadan
2006-07-27
打赏
举报
回复
jsp如下所示(略去部分无关紧要的代码):
<%@ page contentType="text/html; charset=GB2312"
import="java.util.List,java.util.Iterator" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@include file="commonHead.jsp" %>
<body >
<form name="f1" action="importEdiAction.do?method=importEdi" method="POST" enctype="multipart/form-data">
<table width="98%">
<tr>
<td>导入文件</td>
<td><input type="file" name="txtFile" value=""/></td>
</tr>
<tr>
<td colspan="2">
<input name="btnImport" type="button" value="导入" class="formButton00" onclick="doImport()"
style="${importEdiMaintain}"/>
</td>
</tr>
</table>
<input type="hidden" name="txtHiddenFile" value="">
</form>
</body>
</html>
最全的
common
-
File
Upload
.jar包
最全的
common
-
File
Upload
.jar包,里面有三个jar包,绝对你够用
Common
-
File
Upload
带进度条文件上传
Common
-
File
Upload
带进度条文件上传
common
-io,
common
-
file
upload
.jar等jar包
一些前缀是
common
的jar包,希望大家有用吧
common
s-
file
upload
-1.3.1
Apache
Common
s
File
Upload
1.3.1 jar,里面包含通用的上传下载jar文件
common
s-
file
upload
-1.3.1.jar.
common
s-
file
upload
-1.2.1.jar和
common
s-io-1.3.2.jar程序文件
common
s-
file
upload
-1.2.1.jar和
common
s-io-1.3.2.jar 案例上传: http://hi.baidu.com/lichao77821/blog
Web 开发
81,091
社区成员
341,718
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章