struts2上传多文件
来源:互联网 发布:凸优化 公开课 编辑:程序博客网 时间:2024/05/29 17:47
public
class
UploadAction {
private
static
final
long
serialVersionUID = 7738910297605127355L;
//private News news; //注入实体对象
private
static
final
int
BUFFER_SIZE =
16
*
1024
;
// 缓冲-上传字节数组
private
String upfileName;
private
List<File> uploads =
new
ArrayList<File>();
private
List<String> uploadFileNames =
new
ArrayList<String>();
private
List<String> uploadContentTypes =
new
ArrayList<String>();
public
String add() {
int
size = uploadContentTypes.size();
if
(size >
0
) {
for
(
int
i =
0
; i < size; i++) {
String contentype = uploadContentTypes.get(i);
if
(contentype.indexOf(
"image"
) > -
1
) {
File imageFile =
new
File(ServletActionContext.getServletContext().getRealPath(
"/upload/images"
)+
"/"
+ uploadFileNames.get(i));
UploadUtil.copy(uploads.get(i), imageFile, BUFFER_SIZE);
String picturePath =
"/upload/images"
+
"/"
+ uploadFileNames.get(i);
String picName = uploadFileNames.get(i);
// 设置实体对象中的图片地址
// news.setPicturePath(picturePath);
// news.setPictureName(uploadFileNames.get(0));
System.out.println(
"图片地址:"
+ picturePath);
System.out.println(
"图片名称:"
+ picName);
}
/*否则就是上传附件,不是图片
else {
File fujianFile = new File(ServletActionContext.getServletContext().getRealPath("/upload")+ "/" + uploadFileNames.get(1));
UploadUtil.copy(uploads.get(1), fujianFile, BUFFER_SIZE);
// 设置实体对象中的图片地址
// news.setUpfileName(uploadFileNames.get(1));
String picturePath = "/upload/images" + "/"
+ uploadFileNames.get(0);
String picName = uploadFileNames.get(0);
System.out.println("图片地址:" + picturePath);
System.out.println("图片名称:" + picName);
}
*/
}
}
return
"upload"
;
}
public
String getUpfileName() {
return
upfileName;
}
public
void
setUpfileName(String upfileName) {
this
.upfileName = upfileName;
}
public
List<File> getUpload() {
return
this
.uploads;
}
public
void
setUpload(List<File> uploads) {
this
.uploads = uploads;
}
public
List<String> getUploadFileName() {
return
this
.uploadFileNames;
}
public
void
setUploadFileName(List<String> uploadFileNames) {
this
.uploadFileNames = uploadFileNames;
}
public
List<String> getUploadContentType() {
return
this
.uploadContentTypes;
}
public
void
setUploadContentType(List<String> contentTypes) {
this
.uploadContentTypes = contentTypes;
}
}
0 0
- Struts2多文件上传
- struts2多文件上传
- struts2多文件上传
- struts2 多文件上传
- struts2多文件上传
- struts2多文件上传
- struts2多文件上传
- struts2多文件上传
- Struts2多文件上传
- Struts2多文件上传
- Struts2 多文件上传
- struts2多文件上传
- struts2 多文件上传
- Struts2多文件上传
- struts2多文件上传
- struts2 多文件上传
- struts2多文件上传
- struts2多文件上传
- 常用Jquery操作总结
- Java程序员应该了解的10个面向对象设计原则
- redis 常见指令操作
- JAVA加减日期
- Java基础-Java中的Calendar和Date类
- struts2上传多文件
- 对VC初学者的益言
- struts2上传多文件(b)
- 【转载】FckEditor 2.6.3 for Java 2.4 配置
- 【转载】ckeditor 中去掉\'浏览服务器\'按钮
- 判断字符串中包含某个字符串
- 【转载】FCKeditor 2.6.3 与FCKeditor.java 2.4在JSP中配置
- 【转载】Myeclipse10 安装Aptana插件
- iOS适配HTTPS、开启ATS让你的域名更安全
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
奥华生态集成吊顶
奥华吊顶团购
奥华吊顶价格
奥华吊顶怎么样
奥华吊顶好不好
奥华集成吊顶的优缺点
海创集成吊顶
海创
奥南
奥南海滩旅游
南海滩旅游
奥南海滩
奥卡
奥卢
奥古
奥古五王
奥园广场
广州奥园广场
萝岗奥园广场
广州奥园
番禺奥园广场
千灯奥园印象高迪
奥园印象高迪
奥园康城
奥园集团
奥园小区
奥园国际城户型图
奥园房地产
奥园一号
奥园冠军城
奥园养生广场租房
奥园国际
奥园地产怎么样
奥园酒店
奥园集团有限公司
奥园房子
奥园养生广场
奥园开发商
奥园商业集团
奥园地产排名
奥园会展广场