struts之上传文件

本文主要探讨了在Struts框架中实现文件上传的过程,包括关键配置和可能出现的异常处理。通过对上传过程的解析,帮助读者理解如何在Struts中集成文件上传功能。
摘要由CSDN通过智能技术生成
struts之上传文件
用的是struts自带的org.apache.struts.upload.FormFile,这篇文章参考了网上一些资料,在这做个小结,为日后参考。
首先是提交页面,代码如下:

<form action="DownAddSubmit.do" method="post" ENCTYPE="multipart/form-data">
标题:<input size=80 name="downtitle" value=""/><br/>
图片:<input type="file" size="50" name="thePic"/><br/>
文件:<input type="file" size="50" name="theFile"/><br/>
<input type="submit" value="确定"/>
</form>

我这里假设上传2个文件,1个图片,1个别的文件,其中ENCTYPE="multipart/form-data"务必需要这样写的,当然这里也可以
传其他的东西,我传了个标题,文本的,把这个标题传入数据库,把图片和文件上传到服务器空间,同时把这2个文件名字也传
到数据库。
先配置下struts-config.xml,如下:
<form-beans><form-bean name="
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elabor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值