Category: 技术文档
-
jquery ajax 无窗口下载文件
1、jquery 版本 要实现该功能需要使用jquery 3.x版本,这里使用了3.7.0 <script src="/jquery-3.7.0.min.js"></script> 2、实现 $("#btn-export").on('click',function (){ var form_data = new FormData(); form_data.append("account", $('input[name="account"]').val()); $.ajax({ type: "post", url: "/account_export", data:form_data, /* 重点一、processData 和 contentType 都为false*/ processData:false, contentType:false, timeout:0, xhr:function (){ /* 重点二、数据类型 */ var xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; return xhr; }, success: function (file,a,b) { /* 重点三、文件名 */ let filename…
-
IOException: 您的主机中的软件中止了一个已建立的连接。
问题一帮是处理的数据较大,导致链接超时。 接方法及排查位置: 1、前端请求链接超时时间设置 timeout var form_data = new FormData(); form_data.append("param",$("input[name='param']").val()); $.ajax({ url:'/dowloand', type:'POST', data:form_data, processData:false, contentType:false, timeout: 0, //超时时间,单位ms。文件很大这里设置0不做超时处理 xhr:function (){ var xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; return xhr; }, success:function (file){ let a = document.createElement('a'); let url = window.URL.createObjectURL(file); a.href = url; a.download = file.name; a.click(); window.URL.revokeObjectURL(url); }, error: function (a,b,c){ console.log(a);…
-
php 调用java接口签名注意点
json_encode 中文和转义反斜杠问题 $arr = ['name'=>'中文','path'=>'/image/ok.jpg']; echo json_encode($arr); //输出 {"name":"\u4e2d\u6587","path":"\/image\/ok.jpg"} echo "<br/>"; echo json_encode($arr,JSON_UNESCAPED_UNICODE); //输出 {"name":"中文","path":"\/image\/ok.jpg"} echo "<br/>"; echo json_encode($arr,JSON_UNESCAPED_SLASHES); //输出 {"name":"\u4e2d\u6587","path":"/image/ok.jpg"} echo "<br/>"; echo json_encode($arr,320); //输出 {"name":"中文","path":"/image/ok.jpg"} empty 和 数字0 的判断问 $i = 0; echo empty($i)?"true":"false"; //输出 true echo "<br/>"; echo $i==0?"true":"false"; //输出 true echo "<br/>"; echo $i=="0"?"true":"false"; //输出 true echo "<br/>"; //判断失败 if(empty($i)&&$i!=0){ continue;…
-
一个常用的可能都很标准的东西
@Getter @ToString @AllArgsConstructor public enum BaseResponseEnum { CODE_SUCCESS(10000,"请求成功"), CODE_FAIL(10001,"请求失败"), CODE_NOT_ALLOW(10002,"拒绝请求"), CODE_TIMEOUT(10003,"请求超时"), CODE_EXPIRE(10004,"登录超时"); private Integer code; private String msg; } @Data public class BaseResponse<T> { private Boolean success; private Integer code; private String msg; private T data; public static BaseResponse win(){ BaseResponse response = new BaseResponse(); response.setSuccess(true); response.setCode(BaseResponseEnum.CODE_SUCCESS.getCode()); return response; } public static BaseResponse fail(){ BaseResponse…
-
Mybatis-plus 多数源配置
前提 您已掌握mybatis-plus单数据源的使用,不会的前移步上一篇“Mybatis-plus简单使用” 一、依赖 <dependency> <groupId>com.baomidou</groupId> <artifactId>dynamic-datasource-spring-boot-starter</artifactId> <version>3.5.1</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.2.8</version> </dependency> 依赖说明,mybatis plus 数据源连接默认采用druid连接,不存在的时候按以下顺序优先选择 Druid > HikariCp > BeeCp > DBCP2 > Spring Basic 我们一般都采用Druid 对于druid依赖,是选用druid还是选用druid-spring-boot-starter,前者是需要自行配置启动的,而后者是官方配置好的,初学用后者,深入了解配置可以采用前者。 二、配置 spring: datasource: dynamic: primary: db_first #设置默认的数据源或者数据源组 strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 datasource: db_first: url: jdbc:mysql://127.0.0.1:3306/mybatis_one?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8 username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 #type:com.alibaba.druid.pool.DruidDataSource #使用Druid连接池 默认不写,所以db_second也同样使用了Druid连接池 db_second:…
-
mybatis-plus简单使用
前提条件 Msql正常连接 #mysql配置 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mybatis_demo?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 一、依赖 <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.0</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.5.1</version> </dependency> <!– 模板引擎 –> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.0</version> </dependency> 二、配置 @MapperScan("com.mackes.mapper") //*** mapper路径 @Configuration public class MybatisPlusConfig { // 最新版 @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return…
-
手机模拟器默认端口号
手机模拟器的名称 默认端口号 Genymotion模拟器 5555 夜神模拟器 62001/52001 海马玩模拟器 26944 mumu模拟器 7555 天天模拟器 6555 逍遥安卓模拟器 21503 BlueStacks 蓝叠3模拟器 5555 雷神安卓模拟器 5555 腾讯手游助手 5555
-
PHP strtotime 大全
header("Content-type:text/html;charset=utf-8"); date_default_timezone_set('Asia/Shanghai'); echo '当前时间:'.date('Y-m-d H:i:s')."<br>"; echo '当前时间:'.date('Y-m-d H:i:s',strtotime("now")), "<br>"; echo '字符串变时间:'.date('Y-m-d H:i:s',strtotime("10 September 2000")), "<br>"; echo '明天的这个时候:'.date('Y-m-d H:i:s',strtotime("+1 day")), "<br>"; echo '一周后的这个时候:'.date('Y-m-d H:i:s',strtotime("+1 week")), "<br>"; echo '一周 加 2天 加4小时 加 2秒的时间:'.date('Y-m-d H:i:s',strtotime("+1 week 2 days 4 hours 2 seconds")), "<br>"; echo '下周四:'.date('Y-m-d H:i:s',strtotime("next Thursday")), "<br>"; echo '下周一:'.date('Y-m-d H:i:s',strtotime("last Monday")), "<br>"; echo '上月的第一天:'.date('Y-m-d H:i:s',strtotime("first day…
-
TP5.x 微信SDK EasyWechat 安装
TP5.x 微信SDK EasyWechat 安装 EasyWeChat安装 composer require naixiaoxin/think-wechat 初探 微信公众号 use EasyWeChat\Factory; //use think\facade\Env; //tp5.1 class Index{ public function index(){ $config = [ 'app_id' => 'wx3cf0f39249eb0xxx', 'secret' => 'f1c242f4f28f735d4687abb469072xxx', 'token' => 'TestToken', 'response_type' => 'array', 'log' => [ 'level' => 'debug', //'file' => Env::get('root_path').'/runtime/logs/wechat_payment.log', //tp5.1.x //'file' => ROOT_PATH.'/runtime/logs/wechat_payment.log', //tp5.0.x ], //… ]; //$config = config('wechat.payment.default');…
-
Gitee webhook & 宝塔webhook 实现代码从git自动部署到服务器
首先声明该方法不建议使用在生产环境中。 下面是具体步骤 一、在gitee上创建一个仓库(不是自己的肯定不能这么玩的对吧) 二、在宝塔面板上安装“宝塔webhook”软件 三、在服务器上运行命令【$ git config –global credential.helper store】。这一步主要是为了可以自动保存git账户密码,这样不用每次拉去的时候都要输入一遍。 四、在对应的服务器文件目录下运行命令 【$ git clone https://gitee.com/xxxx/xxxx.git】输入账号密码把代码克隆下来。 五、点击“宝塔webhook”软件上的设置按钮,再点击打开中的添加按钮 六、设置对应的信息。名称写自己的。执行代码格式按这么写【cd /www/wwwroot/xxxx && git pull https://gitee.com/xxxx/xxxx.git 2<&1】,然后提交保存即可(前面设置记住git账户密码就是为了方面这里pull的时候不用输入账号密码) 七、点击“查看秘钥”查看url地址和秘钥 八、打开gitee中的对应仓库的“管理”,管理中有个webhook,点击添加,之后填写对应的url和秘钥到对应位置保存就可以了,注意上图中被叉掉的说明部分不要当url复制进去 九、以上设置全部完成后,就可以提交一个代码到git仓库了,然后你去服务器对应目录上查看就能看到你提交的代码已经被pull到服务器了。 说明完毕,祝你可以写一辈子的代码,不被996,不被炒鱿鱼。