1.对数组元素进行条件判断,并获取符合条件的元素index
itemIndex = tempArray.findIndex((value, index, arr) => {
return value._id == 1;
});
2.HTML 图片自适应大小
img{
auto;
height:auto;
max-100%;
max-height:100%;
}
3.H5 使用自定义字体 / 使用下载的字体
@font-face{
font-family:'自定义字体别名';
src:url('自定义字体路径');
}
body{
font-family:'自定义字体别名';
}
4.MySQL 创建存储过程
DELIMITER ;;
DROP PROCEDURE IF EXISTS schema_change;
CREATE PROCEDURE schema_change()
BEGIN
select 1;
END;
CALL schema_change();
DROP PROCEDURE IF EXISTS schema_change;
;;
DELIMITER ;
5.Java 多线程开启
CountDownLatch latch = new CountDownLatch(10);
ExecutorService ex = Executors.newFixedThreadPool(10);
for (int k = 0; k < 10; k++) {
ex.execute(() -> youmethod());
}
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
ex.shutdown();
}
6.Java Spring项目中,获取当前Request请求
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
7.MySql find_in_set(columnName,valueStr)
代替where in ('xx','xx1','xx2');
select * from table where id in ('1','2','2');
select * from table where find_in_set(id,'1,2,3') ;
8.Java List 过滤
cultureList.removeIf(redisLanguagePairCulture::contains);