spring定时任务-文件上传进度条
spring定时任务
导依赖
<!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.3</version>
</dependency>
配置定时任务类
package com.atguigu.scw.portal.service;
import org.springframework.stereotype.Service;
@Service
public class ExampleJob {
public void hello() {
System.out.println("定时任务触发===========>");
}
}
配置定时任务
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
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-4.3.xsd">
<!-- <bean id="exampleJob"
class="com.atguigu.scw.portal.service.ExampleJob"></bean> -->
<!--配置定时任务触发类和方法 -->
<bean id="jobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="exampleJob" />
<property name="targetMethod" value="hello" />
</bean>
<!--配置触发器,指定何时触发 -->
<bean id="cronTrigger"
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobDetail" />
<!-- run every morning at 6 AM -->
<property name="cronExpression" value="*/5 * * * * ?" />
</bean>
<!--配置定时任务调用哪一个触发器 -->
<bean
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
</beans>
cron表达式使用
每隔5秒执行一次:*/5 * * * * ?
每隔1分钟执行一次:0 */1 * * * ?
每天23点执行一次:0 0 23 * * ?
每天凌晨1点执行一次:0 0 1 * * ?
每月1号凌晨1点执行一次:0 0 1 1 * ?
每月最后一天23点执行一次:0 0 23 L * ?
每周星期天凌晨1点实行一次:0 0 1 ? * L
在26分、29分、33分执行一次:0 26,29,33 * * * ?
每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ?
参考
文件上传进度条
ajax异步提交表单$("#subBtn").on('click', function() { return false}是js对象的机制
<button type="submit" id='subBtn' class="btn btn-default">Submit</button>点击按钮直接提交是浏览器的机制
文件上传
表单直接提交action='${ctp}/member/upload' method='post' enctype="multipart/form-data"
<form action='${ctp}/member/upload' method='post' enctype="multipart/form-data">
<div class="form-group">
<input type="file" class="form-control" id="file" name='file'>
</div>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
60%</div>
</div>
<button type="submit" id='subBtn' class="btn btn-default">Submit</button>
</form>
ajax提交type : "post",contentType : false,processData : false
进度条:获取myXhr = $.ajaxSettings.xhr()对象并返回
<form id='submitForm'>
<div class="form-group">
<input type="file" class="form-control" id="file" name='file'>
</div>
<div class="progress" style='display: none;'>
<div class="progress-bar" role="progressbar" aria-valuenow="0"
aria-valuemin="0" aria-valuemax="100" style="width: 0%;">0%</div>
</div>
<button type="submit" id='subBtn' class="btn btn-default">Submit</button>
</form>
<script type="text/javascript">
$("#subBtn").on('click', function() {
var fd = new FormData($("#submitForm")[0]);
$.ajax({
url : "${ctp}/member/upload",
data : fd,
type : "post",
contentType : false,
processData : false,
//获取ajaxSettings中的xhr对象,为它的upload属性绑定progress事件的处理函数
xhr : function() {
myXhr = $.ajaxSettings.xhr()
//检查upload属性是否存在
if (myXhr.upload) {
//绑定progress事件的回调函数
myXhr.upload.addEventListener('progress',
progressHandlingFunction, false)
}
//xhr对象返回给jQuery使用
return myXhr;
},
success : function(result) {
console.log("result==========>", result)
},
error : function(e) {
console.log('e=========>', e)
}
})
return false
})
var progressHandlingFunction = function(e) {
var curr = e.loaded
var total = e.total
process = curr / total * 100
console.log('上传进度============>', process)
$('.progress').attr('style', 'display:show;')
$('.progress-bar').html(process + '%')
$('.progress-bar').attr('style', 'width:' + process + '%;')
}
</script>
图片预览
$("#ad_file_input").on('change', function(event) {
$(this).empty()
$(this).parent('.form-group').next('.form-group').find('.imgdiv').empty()
fileList = event.currentTarget.files
log('fileList==============>', fileList)
var URL = window.URL || window.webkitURL
var imgURL
//遍历上传的文件进行显示
$.each(fileList, function (index, item) {
//创建一个临时的url地址
imgURL = URL.createObjectURL(item)
log('this=========>',this)
log('item==========>',item)
$('#ad_file_input').parent(".form-group").next(".form-group").find(".imgdiv").append("<img src='"+imgURL+"' style='width:200px;height:220px;'/>").append('<p>'+item.name+'<p>')
})
})
spring定时任务-文件上传进度条的更多相关文章
- HTML5矢量实现文件上传进度条
在HTML中,在文件上传的过程中,很多情况都是没有任何的提示,这在体验上很不好,用户都不知道到时有没有在上传.上传成功了没有,所以今天给大家介绍的内容是通过HT for Web矢量来实现HTML5文件 ...
- 基于HT for Web矢量实现HTML5文件上传进度条
在HTML中,在文件上传的过程中,很多情况都是没有任何的提示,这在体验上很不好,用户都不知道到时有没有在上传.上传成功了没有,所以今天给大家介绍的内容是通过HT for Web矢量来实现HTML5文件 ...
- PHP中使用Session配合Javascript实现文件上传进度条功能
Web应用中常需要提供文件上传的功能.典型的场景包括用户头像上传.相册图片上传等.当需要上传的文件比较大的时候,提供一个显示上传进度的进度条就很有必要了. 在PHP .4以前,实现这样的进度条并不容易 ...
- iOS_文件上传进度条的实现思路-AFNettworking
iOS_文件上传进度条的实现思路-AFNettworking //要上传的文件名,在这里我使用当前日期做为文件的名称 NSString * fileName =[NSString stringWith ...
- asp.net文件上传进度条研究
文章:asp.net 文件上传进度条实现代码
- Layui多文件上传进度条
Layui原生upload模块不支持文件上传进度条显示,百度,谷歌找了一下不太适用.后面找到一个别人修改好的JS,替换上去,修改一下页面显示即可使用,一下是部分代码 HTML: <div cla ...
- 利用Bootstrap简单实现一个文件上传进度条
© 版权声明:本文为博主原创文章,转载请注明出处 说明: 1. 使用commons-fileupload.jar实现文件上传及进度监听 2. 使用bootstrap的进度条进行页面显示 3. 因为进度 ...
- vue多文件上传进度条 进度不更新问题
转自 hhttp://www.cnblogs.com/muge10/p/6767493.html 感谢这位兄弟的文章,之前因为这个问题 ,我连续在sgmentflow上提问过多次,完全没人能回答.谢谢 ...
- layui文件上传进度条(模拟)
1.修改上传组件js(没测) https://blog.csdn.net/weixin_42457316/article/details/81017471 https://www.cnblogs.co ...
随机推荐
- 学习HTML之后的感受
自从学习了HTML之后,感觉自己每天面对密密麻麻的代码,都有了一种密集恐惧症的感觉,作为一个计算机行业的小白,我十分渴望在计算机行业有所建树,以前计算机对我来说是一个神秘的领域.现在我正在努力进入这个 ...
- 洛谷 P2341 【受欢迎的牛】
题库:洛谷 题号:2341 题目:受欢迎的牛 link:https://www.luogu.org/problemnew/show/P2341 思路:因为奶牛的爱慕关系具有传递性,所以每个环(强连通分 ...
- view生命周期
- P3469 [POI2008]BLO-Blockade 割点 tarjan
题意 给定一个无向图,问删掉点i,图中相连的有序对数.(pair<x, y> , x != y);求每个点对应的答案 思路 首先我们可以发现,如果这个点不是割点,那么答案就是n-1,如果是 ...
- Gym 100851 题解
A: Adjustment Office 题意:在一个n*n的矩阵,每个格子的的价值为 (x+y), 现在有操作取一行的值,或者一列的值之后输出这个和, 并且把这些格子上的值归0. 题解:模拟, 分成 ...
- poj 3177 Redundant Paths(tarjan边双连通)
题目链接:http://poj.org/problem?id=3177 题意:求最少加几条边使得没对点都有至少两条路互通. 题解:边双连通顾名思义,可以先求一下连通块显然连通块里的点都是双连通的,然后 ...
- Python初步接触与学习
Python的发展史与特点 诞生与发展史 1989,为了度过圣诞假期,Guido开始编写Python语言编译器.Python这个名字来自Guido的喜爱的电视连续剧<蒙蒂蟒蛇的飞行马戏团> ...
- Python(Head First)学习笔记:五
5 推导数据:处理数据.格式.编码.解码.排序 处理数据:从Head First Python 上下载资源文件,即:james.txt,julie.txt,mikey.txt,sarah.txt. 实 ...
- [币严区块链]BitcoinCash - BCH钱包地址生成与扫块充值监控(JAVA版)
本文的方案无需自建节点,因为BCH当前区块数据大小已经达到200G以上,BTC区块数据也已超过300G,若每个币都自建节点,对云服务器的消耗会非常大. 认识BitcoinCash(BCH) Bitco ...
- Spring系列__04AOP
AOP简介 今天来介绍一下AOP.AOP,中文常被翻译为"面向切面编程",其作为OOP的扩展,其思想除了在Spring中得到了应用,也是不错的设计方法.通常情况下,一个软件系统,除 ...