读取网络图片时遇到的坑
发表于|更新于
|浏览量:
读书越多,越感到腹中空虚。 ——雪莱
今天在使用java读取网络图片的时候遇到一个问题
图片粘贴到浏览器的地址栏上可以打开
但使用java读取就报400
最后发现原来是url编码问题
把url中的中文、空格或者特殊字符之类的转换一下就好了
1 | java.net.URLEncoder.encode("www.阿超.com", "utf-8") |
相关推荐
2023-06-14
spring获取AliasFor增强的注解
无论何时,别让你自己卷进去反对他人。——歌德 此处是关于issue:https://gitee.com/dromara/stream-query/issues/I7BSNV 这里使用的一个自定义的@Table注解+@AliasFor来增强@TableName 1234567891011121314151617181920212223242526272829303132/* * 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&q...
2024-06-24
MybatisPlus自动填充忽略存在值直接填充
再也无需前思后想,一切岂非已然过往。——《且听风吟》 代码如下,主要是重写strictFillStrategy方法 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import cn.dev33.satoken.stp.StpUtil;import cn.hutool.core.lang.Opt;import com.baomidou.mybatisplus.core.MybatisConfiguration;import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;import com.baomidou.mybatisplus.core.handlers.StrictFill;import com.baomidou.mybatisplus.extension.plugin...
2022-04-16
springboot连接oracle
她愿意服从,因为她能够统治。——巴尔扎克《奇双会》 首先引入GAV 12345<dependency> <groupId>org.zenframework.z8.dependencies.commons</groupId> <artifactId>ojdbc6</artifactId> <version>2.0</version></dependency> 然后修改application中url和驱动 123datasource: driver-class-name: oracle.jdbc.OracleDriver url: jdbc:oracle:thin:@localhost:1521/数据库名
2023-06-03
java图片切片
女人绝不会被奉承解除武装,而男人大都会陷落。——王尔德 可以使用hutool的ImgUtil.slice 1ImgUtil.slice(FileUtil.file("d:/test/logo.jpg"), FileUtil.file("d:/test/dest"), 200, 150); 123456789 /** * 图像切片(指定切片的宽度和高度) * * @param srcImageFile 源图像 * @param descDir 切片目标文件夹 * @param destWidth 目标切片宽度。默认200 * @param destHeight 目标切片高度。默认150 */public static void slice(final File srcImageFile, final File descDir, final int destWidth, final int destHeight) 而且除了指定宽度和高度的,还可以使用: 12345678910/** * 图像切割(指定切片的行数和列数...
2024-02-12
异步转Mono
小利不争,小忿不发,可以合众。——傅昭 今天分享一个异步方法转Mono的方式,利用reactor.core.publisher.Mono#create: 1234567891011return Mono.create(sink -> rtmClient.subscribe(channelName, options, new ResultCallback<Void>() { @Override public void onSuccess(Void unused) { sink.success(unused); } @Override public void onFailure(ErrorInfo errorInfo) { sink.error(new IllegalStateException(errorInfo.getErrorReason())); }})); 即可实现
2021-04-08
mp数据源加密
不宝金玉,而忠信以为宝。——《礼记》 在开发中,我们难免可能会担心数据库账号密码泄露 我们可以使用mybatis-plus自带的数据安全保护进行加密 123456789101112public static void main(String[] args) throws Throwable { // 生成 16 位随机 AES 密钥 String randomKey = AES.generateRandomKey(); // 随机密钥加密 String url = AES.encrypt("jdbc:mysql://localhost:3306/ruben?autoReconnect=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useUnicode=true&characterEncoding=utf-8&useSSL=false&nullCatalogMeansCurrent=true&serverTimezone=Asia/Shanghai&...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog