- 浏览: 767147 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (386)
- Linux (36)
- Tomcat (6)
- windows (8)
- Apache (10)
- Java (25)
- jquery (7)
- Jquery 插件 (3)
- Oracle (5)
- Oracle SQL (68)
- Spring (15)
- 开发工具 (6)
- Struts (20)
- js (14)
- Project Code (2)
- Project Code Tomcat (1)
- libset (1)
- JSP (8)
- arithmetic (2)
- 浏览器 (1)
- extjs (3)
- 学习网站 (5)
- 生活情感 (0)
- 电话号码算法 (3)
- 快捷键 (1)
- 转载 (1)
- Dos命令 (2)
- services (1)
- Resources (1)
- 行业积累 (3)
- 项目积累 (3)
- Web (3)
- 文档 (1)
- JavaEE (2)
- JSF (3)
- http (3)
- JS窗口 (1)
- Html (4)
- Flex (1)
- 资讯 (2)
- 项目规范 (1)
- Struts s:property textarea中默认值用 (1)
- Quartz 2.0.2 (12)
- 1天有多少毫秒 (1)
- 专题 (1)
- intellij idea 10 CD-KEY (1)
- restlet (4)
- Mail (1)
- Excel (3)
- Menu (1)
- Big Data技术综述 (1)
- Quart 1 (1)
- nosql (1)
- linux远程 (1)
- jdk (5)
- wind7 (1)
- 虚拟人 (0)
- 虚拟机 (1)
- 终端 (1)
- Ubuntu (16)
- Myeclipse (2)
- Wmware (1)
- eclipse (2)
- css (2)
- csv (1)
- 开源 (1)
- plsql (2)
- cassandra (4)
- maven (1)
- hadoop (2)
- mysql (1)
- spring security (1)
- tools (1)
- jdbc (2)
- exception (2)
- 硬盘数据备份 (1)
- dwr (1)
- svn (1)
- PowerDesigner15使用时的十五个问题 (1)
- tomcat 项目发部路径 (1)
- js 暂停执行 (1)
- jquery jqgrid 格式化数据显示 (1)
- js 代码模板 (1)
- strutss2 直接跳转到jsp页面 (1)
- servlet (1)
- jdbc spring (1)
- js学习网站 (1)
- 自学考试 (2)
- hibernate (2)
- eos (1)
- c (4)
- 黑马 (2)
- 大数据 (2)
- 实战云大数据案例分享 (0)
- Spark (2)
- Flink (1)
最新评论
-
coosummer:
推荐使用http://buttoncssgenerator.c ...
jquery button 漂亮 -
thinktothings:
Array_06 写道你好,我是一名刚毕业学生,我以后就是做J ...
如何转型架构师 -
thinktothings:
软考,考有职业资格证,有系统的知识体系学习
如何转型架构师 -
Array_06:
你好,我是一名刚毕业学生,我以后就是做Java的架构师,那请问 ...
如何转型架构师 -
beykery:
你这也太复杂了。。。。jsf2不应该是这样的。。。。
JSF2.0的一个简单Demo
struts2文件上传
<constant name="struts.codebehind.defaultPackage" value="person" />
actoin返回路径(如jsp路径时省掉包路径,包路径跟文件夹是一样的)
struts-fileupload.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="fileupload" extends="struts-default" namespace="/fileupload">
<action name="upload"
class="org.apache.struts2.showcase.fileupload.FileUploadAction"
method="input">
<result>upload.jsp</result>
</action>
<action name="doUpload"
class="org.apache.struts2.showcase.fileupload.FileUploadAction"
method="upload">
<result name="input">upload.jsp</result>
<result>upload-success.jsp</result>
</action>
</package>
</struts>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.i18n.reload" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.codebehind.defaultPackage" value="person" />
<include file="struts-fileupload.xml"/>
<!-- Add packages here -->
</struts>
java
/*
* $Id: FileUploadAction.java 476710 2006-11-19 05:05:14Z mrdon $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.fileupload;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import com.opensymphony.xwork2.ActionSupport;
/**
* Show case File Upload example's action. <code>FileUploadAction</code>
*
*/
public class FileUploadAction extends ActionSupport {
private static final long serialVersionUID = 5156288255337069381L;
private String contentType;
private File upload;
private String fileName;
private String caption;
// since we are using <s:file name="upload" .../> the file name will be
// obtained through getter/setter of <file-tag-name>FileName
public String getUploadFileName() {
return fileName;
}
public void setUploadFileName(String fileName) {
this.fileName = fileName;
}
// since we are using <s:file name="upload" ... /> the content type will be
// obtained through getter/setter of <file-tag-name>ContentType
public String getUploadContentType() {
return contentType;
}
public void setUploadContentType(String contentType) {
this.contentType = contentType;
}
// since we are using <s:file name="upload" ... /> the File itself will be
// obtained through getter/setter of <file-tag-name>
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String input() throws Exception {
return SUCCESS;
}
public String upload() throws Exception {
if(upload !=null && upload.exists() && upload.isFile() ){
BufferedReader bufferdReader=new BufferedReader(new InputStreamReader(new FileInputStream(upload),"GBK"));
String strTem="";
while((strTem=bufferdReader.readLine())!=null){
System.out.println(strTem);
}
}
return SUCCESS;
}
}
- Struts2FileUpload.zip (3.3 MB)
- 下载次数: 0
- Struts2FileUpload2.zip (3.3 MB)
- 下载次数: 0
- struts2文件上传下载.zip (7.2 MB)
- 下载次数: 0
发表评论
-
strutss2 直接跳转到jsp页面
2012-10-23 21:32 884public String execute() ... -
strtus2文件下载中文文件名乱码问题
2012-09-15 16:39 887strtus2文件下载中文文件名乱码问题 java.net. ... -
struts2 jsp中取 action中的值
2012-09-13 15:24 855String[] manager_range_s; show ... -
strunts文件上传总大小设置
2012-09-05 23:27 841strunts文件上传总大小设置 str ... -
struts2 当类型转换错误时输出自己的错误提示信息
2012-05-29 12:01 670http://javaextjs.iteye.com/blog ... -
Struts2.0 基本的启动项目
2012-05-25 11:00 949Struts2.0 基本的启动项目 包含用到 ... -
html页面刷新就跳转
2012-05-21 16:00 964<!DOCTYPE HTML PUBLIC " ... -
struts list
2012-03-27 17:03 805struts自定义list <s:sel ... -
FreeMarker template error!
2012-03-20 13:27 1924FreeMarker template error! ... -
Struts2得到Application
2011-03-22 11:50 1030ActionContext ctx = ActionConte ... -
<iterator> 标签中 中循环 <s:checkbox > 标签
2011-03-17 11:17 2382<s:iterator valu ... -
struts2在页面获得浏览器请求参数值
2011-02-15 13:24 1125<s:text name="%{vc2cuna ... -
Struts2.0中Action直接返回字符串
2011-01-30 11:27 12640对于Struts2中Action中返回字符串的处理,比如做级联 ... -
struts2.0.14-doubleselect-bg
2011-01-26 12:21 853http://blog.sina.com.cn/s/blog_ ... -
struts2.0.14-doubleselect 用来作级联 官方demo
2011-01-26 11:18 1396官方demo <s:form name=" ... -
struts2.0.14-doubleselect 用来作级联
2011-01-26 11:18 1038官方demo <s:doubleselect lab ... -
struts2-blank-2.0.14
2011-01-26 10:38 819struts2-blank-2.0.14 基本环境,能跑 ... -
struts2-blank-2.0.14
2011-01-26 10:38 942struts2-blank-2.0.14 基本环境,能跑 ... -
Action得到HttpServletRequestt,HttpServletResponse
2010-10-25 08:32 1037ActionContext ctx = Action ...
相关推荐
struts2文件上传和下载 struts2文件上传和下载 struts2文件上传和下载 struts2文件上传和下载 struts2文件上传和下载
struts2 文件上传 struts2上传标签file fileuploadstruts2 文件上传 struts2上传标签file fileuploadstruts2 文件上传 struts2上传标签file fileupload
struts2文件上传实例,程序员宝典......
里面包括的是实现struts2文件上传所需要的全部jar包
Struts2文件上传
Struts2 文件上传
Struts2文件上传源码 Struts2文件上传源码 Struts2文件上传源码 Struts2文件上传源码 Struts2文件上传源码
struts2文件上传与下载,eclipse与myeclipse导入即可使用的代码,简单易懂,希望对你有帮助,喜欢的给个五星评价,谢谢!!!
Struts 2是通过Commons FileUpload文件上传。Commons FileUpload通过将HTTP的数据保存到临时文件夹,然后Struts使用fileUpload拦截器将文件绑定到Action的实例中。从而我们就能够以本地文件方式的操作浏览器上传的...
http://blog.csdn.net/johnjobs/article/details/8076832博文中附件的下载链接