Download File Streams with Axios
Download file streams with Axios
download.js
const axios = require('axios').default; // or import axios from 'axios' |
Notice:
responseType: 'blob'
filename = decodeURI(filename)
article.vue
<template> |
Download file streams with Axios
download.js
const axios = require('axios').default; // or import axios from 'axios' |
Notice:
responseType: 'blob'
filename = decodeURI(filename)
article.vue
<template> |
Here are several ways to access parent context inside child context.
An arrow function does not have its own bindings to this
or super
, this
is inherited from the scope. In regular function, this
is the function itself (it has its own scope).
getData() { |
getData() { |
Put files into /public
directory
Write your download link
Download /public/pdf/instruction.pdf
<a href="/pdf/instruction.pdf" download>download instruction</a> |
Preview and download /public/pdf/instruction.pdf
<a href="/pdf/instruction.pdf" target="_blank">download instruction</a> |
In Vue, the parent-child component relationship can be summarized as props down, events up. The parent passes data down to the child via props, and the child sends messages to the parent via events…
parent.vue
<template> |
Child.vue
<template> |
Call child methods by ref of Vue 2
parent.vue
<div class="form"> |
this.$refs.childComponentRef.doSomething(); |
Call parent methods by props
parent.vue
<div class="form"> |
child.vue
props: { |
Update child components status
Update parent components status
类型改变,如 Integer 改为 String 或 Integer 改为 Long。
当成员变量的数据类型改变后,直接量与成员变量比较时,比较结果可能和之前的结果不同。如:
new Integer(1).equals(new Long(1)) // 返回 false |
发生错误的场景,如:
Integer type1 = 1; |
解决方法:与该成员变量的比较的值,数据类型要保持一致。
若该变量作为 map 的 key 时,可能出现新的数据类型在 map 中找不到对应的 key。
HashMap put(key, value) 方法有指定数据类型的约束,而 get(Object key) 方法没有对应的数据类型约束。字段类型改变后,put 方法有错误提示,而 get 方法没有提示。在 map 对象中不同的数据类型的 key 是不同的 key,从而会出现改完数据类型后找不到对应的 key。
Map<Integer, String> map = new HashMap() |
解决方法:put(key, value) 和 get(Object key) 的 key 的数据类型要保持一致。
若该变量作为方法的参数时,存在多个重载方法,改完类型后,可能调用的不是之前的方法。如存在重载方法 getById(Integer id) 和 getById(Serializable id)。
解决方法:检查该成员变量作为参数调用方法的地方,跳转的方法是不是之前的方法。
import com.fasterxml.jackson.core.JsonGenerator; |
public interface NameValueEnum { |
@JsonSerialize(using = NameValueEnumSerializer.class) |
public class Task extends BaseEntity { |
import com.fasterxml.jackson.core.JsonParser; |
@JsonDeserialize(using = CommaSeparatedStrToListJsonDeserializer.class) |
public class JsonArrayToStringDeserializer extends JsonDeserializer<String> { |
@JsonDeserialize(using = JsonArrayToStringDeserializer.class) |
useUnicode=true |
zeroDateTimeBehavior=convertToNull |
tinyInt1isBit=false |
serverTimezone=GMT%2B8 |
useSSL
For 8.0.12 and earlier: Use SSL when communicating with the server (true/false), default is ‘true’ when connecting to MySQL 5.5.45+, 5.6.26+ or 5.7.6+, otherwise default is ‘false’.
For 8.0.13 and later: Default is ‘true’. DEPRECATED. See sslMode property description for details.
autoReconnect
Should the driver try to re-establish stale and/or dead connections
maxReconnects
Maximum number of reconnects to attempt if autoReconnect is true, default is ‘3’.
useSSL=true |
initialTimeout
If autoReconnect is enabled, the initial time to wait between re-connect attempts (in seconds, defaults to ‘2’).
connectTimeout
Timeout for socket connect (in milliseconds), with 0 being no timeout. Only works on JDK-1.4 or newer. Defaults to ‘0’.
socketTimeout
Timeout (in milliseconds) on network socket operations (0, the default means no timeout).
Using MyBatis to query DATETIME type column data from MySQL table, if the column value is 0000-00-00 00:00:00
, the program will throw exception Java.sql.SQLException
. The following are the column properties.
pubtime DATETIME NULL DEFAULT NULL |
Error attempting to get column 'pubtime' from result set. Cause: java.sql.SQLException: Zero date value prohibited |
To set up zeroDateTimeBehavior=convertToNull
in JdbcUrl. zeroDateTimeBehavior
values can be EXCEPTION
, ROUND
, and CONVERT_TO_NULL
. The default value of zeroDateTimeBehavior
is EXCEPTION
.
driver-url=jdbc:mysql://127.0.0.1/test?zeroDateTimeBehavior=convertToNull |
driver-url=jdbc:mysql://127.0.0.1/test?zeroDateTimeBehavior=round |
When MySQL database is in the face of 0000-00-00 00:00:00
date processing, if not set corresponding countermeasures, it will produce an exception.
Downloading the Activiti UI WAR file from the Activiti website.
Unzip activiti-6.0.0.zip
.
Copy the activiti-6.0.0/wars/activiti-app.war
to the webapps
directory of Tomcat.
Updating configurations in activiti-app/WEB-INF/classes/META-INF/activiti-app/activiti-app.properties
datasource.driver=com.mysql.cj.jdbc.Driver |
Adding MySQL 8 driver mysql-connector-java-8.0.19.jar to lib directory activiti-app/WEB-INF/lib
.
Creating database activiti6ui
that configuring in activiti-app/WEB-INF/classes/META-INF/activiti-app/activiti-app.properties
.
Executing following Activiti initial SQL files:
activiti-6.0.0/database/create/activiti.mysql.create.engine.sql
activiti-6.0.0/database/create/activiti.mysql.create.history.sql
activiti-6.0.0/database/create/activiti.mysql.create.identity.sql
Start Tomcat by running the startup.bat or startup.sh scripts in the bin folder of Tomcat.
When Tomcat is started open your browser and go to http://localhost:8080/activiti-app. Login with admin and password test.
The Solution
@Component
inject the bean to the Spring IoC container.@Value
read application configurations of Spring into non-static fields.InitializingBean
override afterPropertiesSet()
method. Assigning non-static field values to static field values in afterPropertiesSet()
method.For example:
@Component
public class FileUploadUtils implements InitializingBean
{
private static String endpoint;
private static String accessKeyId;
private static String accessKeySecret;
private static String bucketName;
private static OSSClient ossClient;
@Value("${app.fileUpload.oss.endpoint}")
private String getEndpoint;
@Value("${app.fileUpload.oss.accessKeyId}")
private String getAccessKeyId;
@Value("${app.fileUpload.oss.accessKeySecret}")
private String getAccessKeySecret;
@Value("${app.fileUpload.oss.bucketName}")
private String getBucketName;
@Override
public void afterPropertiesSet() throws Exception {
endpoint = getEndpoint;
accessKeyId = getAccessKeyId;
accessKeySecret = getAccessKeySecret;
bucketName = getBucketName;
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
}
}