<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生成绩信息</title>
<link rel="stylesheet" type="text/css"
href="<%=basePath%>jquery/Huploadify-V2.1.2/Huploadify.css">
<script type="text/javascript"
src="<%=basePath%>jquery/Huploadify-V2.1.2/jquery.js"></script>
<script type="text/javascript"
src="<%=basePath%>jquery/Huploadify-V2.1.2/jquery.Huploadify.js"></script>
</head>
<script type="text/javascript">
$(function(){
var up = $('#upload').Huploadify({
auto:false,
fileTypeExts:'*.jpg;*.png;*.exe;*.mp3;*.mp4;*.zip;*.doc;*.docx;*.ppt;*.pptx;*.xls;*.xlsx;*.pdf',
multi:true,
fileSizeLimit:99999999,
breakPoints:true,
saveInfoLocal:true,
showUploadedPercent:true,//是否实时显示上传的百分比,如20%
showUploadedSize:true,
removeTimeout:9999999,
uploader:'<%=basePath%>'+ 'fileUpload',
onUploadStart:function(){
//up.settings('formData', {aaaaa:'1111111',bb:'2222'});
up.Huploadify('settings','formData', {aaaaa:'1111111',bb:'2222'});
},
onUploadSuccess:function(file){
//alert('上传成功');
},
onUploadComplete:function(){
//alert('上传完成');
},
/*getUploadedSize:function(file){
var data = {
data : {
fileName : file.name,
lastModifiedDate : file.lastModifiedDate.getTime()
}
};
var url = 'http://localhost/uploadfile/';
var uploadedSize = 0;
$.ajax({
url : url,
data : data,
async : false,
type : 'POST',
success : function(returnData){
returnData = JSON.parse(returnData);
uploadedSize = returnData.uploadedSize;
}
});
return uploadedSize;
} */
});

$('#btn1').click(function(){
up.stop();
});
$('#btn2').click(function(){
up.upload('*');
});
$('#btn3').click(function(){
up.cancel('*');
});
$('#btn4').click(function(){
up.disable();
});
$('#btn5').click(function(){
up.ennable();
});

});
</script>
<body>
<div id="upload"></div>
<button id="btn1">stop</button>
<button id="btn2">upload</button>
<button id="btn3">cancel</button>
<button id="btn4">disable</button>
<button id="btn5">ennable</button>
</body>
</html>

/**
* 查询学生信息列表
*
* @param name
* @return
* @throws NamingException
* @throws SQLException
*/
@ResponseBody
@RequestMapping(value = "/fileUpload", method = RequestMethod.POST)
public String fileUpload(@RequestParam Map<String, Object> map, HttpServletRequest request,
HttpServletResponse response, @RequestParam(value = "file", required = false) MultipartFile file) {
try {
String fileName = request.getParameter("fileName");
byte[] bytes = file.getBytes();
System.out.println(file.getOriginalFilename());
String uploadDir = request.getRealPath("/") + "upload";
File dirPath = new File(uploadDir);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
String sep = System.getProperty("file.separator");
File uploadedFile = new File(uploadDir + sep + fileName);
FileCopyUtils.copy(bytes, uploadedFile);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
return "ok";
}

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
p:defaultEncoding="UTF-8" />
</beans>

Huploadify V2.1+ SpringMVC上传文件的实现的更多相关文章

  1. 2. SpringMVC 上传文件操作

    1.创建java web项目:SpringMVCUploadDownFile 2.在项目的WebRoot下的WEB-INF的lib包下添加如下jar文件 com.springsource.com.mc ...

  2. springmvc上传文件,抄别人的

    SpringMVC中的文件上传 分类: SpringMVC 2012-05-17 12:55 26426人阅读 评论(13) 收藏 举报 stringuserinputclassencoding 这是 ...

  3. 使用springMVC上传文件

    control层实现功能: @RequestMapping(value="upload2") public String upLoad2(HttpServletRequest re ...

  4. SpringMVC上传文件(图片)并保存到本地

    SpringMVC上传文件(图片)并保存到本地 小记一波~ 基本的MVC配置就不展示了,这里给出核心代码 在spring-mvc的配置文件中写入如下配置 <bean id="multi ...

  5. SpringMVC上传文件总结

    如果是maven项目 需要在pom.xml文件里面引入下面两个jar包 <dependency> <groupId>commons-fileupload</groupId ...

  6. SpringMVC 上传文件 MultipartFile 转为 File

    在使用 SpringMVC 上传文件时,接收到的文件格式为 MultipartFile,但是在很多场景下使用都需要File格式的文件,记录下以便日后使用. 以下mFile为MultipartFile文 ...

  7. springmvc 上传文件时的错误

    使用springmvc上传文件一直失败,文件参数一直为null, 原来是配置文件没写成功. <bean id="multipartResolver" class=" ...

  8. SpringMVC上传文件的三种方式(转)

    直接上代码吧,大伙一看便知 这时:commonsmultipartresolver 的源码,可以研究一下 http://www.verysource.com/code/2337329_1/common ...

  9. SpringMVC上传文件的三种方式

    直接上代码吧,大伙一看便知 这时:commonsmultipartresolver 的源码,可以研究一下 http://www.verysource.com/code/2337329_1/common ...

随机推荐

  1. The D Programming Language 书评

    此书的作者 Andrei Alexandrescu 作为前 C++ 社区的一朵奇葩,因为实在是不满 C++ 标准委员会的官僚作风,跳槽到了 D 社区,成为了 D 发明人 Walt Brightman ...

  2. vs中nuget命令的用法

    一.安装 1.安装指定版本类库install-package <程序包名> -version <版本号>        ( 注意:-version <版本号> 可以 ...

  3. 【node+小程序+web端】简单的websocket通讯

    [node+小程序+web端]简单的websocket通讯 websoket是用来做什么的? 聊天室 消息列表 拼多多 即时通讯,推送, 实时交互 websoket是什么 websocket是一个全新 ...

  4. sublime中如何用less实现css预编译

    实现css预编译的方式有很多,听说glup很流行而且功能也很强大,但是就目前的工作而言,仅要css预编译和YUIcompress就够了,接下来切入正题 Less 是一门 CSS 预处理语言,它扩展了 ...

  5. 2016年度最受欢迎的100个 Java 库

    [编者按]本文作者为 Henn Idan,主要介绍基于 GitHub 中的数据分析,得出的2016年度最受欢迎的100个 Java 库.本文系国内 ITOM 管理平台 OneAPM 编译呈现. 谁拔得 ...

  6. AWS CSAA -- 04 AWS Object Storage and CDN - S3 Glacier and CloudFront(一)

    013 S3 - 101 014 Create an S3 Bucket - Lab

  7. InfoPath读取数据库

    public void LoadBtn_Clicked(object sender, ClickedEventArgs e) { // 配置连接字符串 using (SqlConnection con ...

  8. Python socket应用

    Server端: #-*- coding: UTF-8 -*- import socket,time host='192.168.0.9' port=12307 s=socket.socket(soc ...

  9. Q矩阵输出

    程序启动时: 1.Q矩阵在InitQX中对角阵赋初值为0.25,GPS卫星数6 2.Q矩阵初值在初始化时由GetBL获得,改变Q对角阵 Q初值第0个卫星 10000000000.000 X初值第0个卫 ...

  10. postgresql----几何类型和函数

    postgresql支持的几何类型如下表: 名字 存储空间 描述 表现形式 point 16字节 平面上的点 (x,y) line 32字节 直线 {A,B,C} lseg 32字节 线段 ((x1, ...