java生成快递单并调用打印机打印
生成快递单过程中需要生成条形码,生成条形码可参考:https://www.cnblogs.com/linbky/p/12091248.html
下面这段代码生成的快递单是完全符合京东快递的10 x 13尺寸的快递单,业务需求是移动端操作下单,提交并同步打印快递单。
package com.yutong.common.utils.print; import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.ImageObserver;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.util.Date; import javax.imageio.ImageIO;
import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.PrinterName; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import com.yutong.common.utils.DateUtils;
import com.yutong.common.utils.StringUtils; public class Graphic implements ImageObserver, Printable{ private static Logger logger = LoggerFactory.getLogger(Graphic.class); private static WayBillReceive wayBillReceive; private static String filePath; @Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { //获取画笔
Graphics2D g2=(Graphics2D) graphics; //设置画笔颜色
g2.setPaint(Color.black); g2.translate(pageFormat.getImageableX(),pageFormat.getImageableY()); Font font=new Font("黑体",Font.BOLD,36);
g2.setFont(font);
//外框 上9.6cm ,270px+10(外边距)
g2.drawLine(10, 10, 280, 10); //10
//外框 左5.4cm 151px+10(外边距)
g2.drawLine(10, 10, 10, 161);
//外框 下
g2.drawLine(10, 161, 280, 161);
//外框 右
g2.drawLine(280, 10, 280, 161); //中间第一横
g2.drawLine(10, 66, 280, 66); //56+10
//中间第二横
g2.drawLine(10, 100, 280, 100);//34+66 //中间第三横
g2.drawLine(10, 117, 280, 117);//17+100
//中间第四横
g2.drawLine(173, 139, 280, 139);//22+117 //中部第一条竖线
g2.drawLine(30, 100, 30, 161);
//中部第二条竖线
g2.drawLine(145, 66, 145, 117);
//中部第三条竖线
g2.drawLine(173, 100, 173, 161);
//中部第四条竖线
g2.drawLine(201, 117, 201, 161); //上半部分
//--------------------------------------------------------
//下半部分 //上
g2.drawLine(10, 179, 280,179); //179
//左
g2.drawLine(10, 179, 10, 299);
//下
g2.drawLine(10, 299, 280, 299);
//右
g2.drawLine(280,179, 280, 299); //中部第一条横线
g2.drawLine(10, 199, 280, 199); //20+179 //中部第二条横线
g2.drawLine(10, 245, 280, 245); //45+199 //中部第三条横线
g2.drawLine(10, 265, 280, 265); //20+245 //中部第四条横线
g2.drawLine(10, 282, 280, 282);//17+265 //中部第一条竖线
g2.drawLine(85, 245, 85, 265);
//中部第二条竖线
g2.drawLine(182, 199, 182, 299);
//中部第三条竖线
g2.drawLine(224, 245, 224, 265); String fileName = StringUtils.getUuid()+".png";
try { font=new Font("黑体",Font.PLAIN,11);
g2.setFont(font);
g2.drawString("众", 268, 22); //包裹号条形码
Image image = ImageIO.read(BarCodeUtil.generateBarCode(wayBillReceive.getDeliveryId()+"-1-1-", filePath+fileName));
g2.drawImage(image, 12, 12, 255, 52, this); font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
//重量
g2.drawString((wayBillReceive.getWeight()==null?0.00:wayBillReceive.getWeight().doubleValue())+" KG", 220, 64); //始发地
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
g2.drawString("始发地:"+wayBillReceive.getSourceSortCenterName(), 13, 76);
font=new Font("黑体",Font.BOLD,20);
g2.setFont(font);
g2.drawString(wayBillReceive.getSourceCrossCode()+"-"+wayBillReceive.getSourceTableTrolleyCode(), 20, 95); //目的地
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
g2.drawString("目的地:"+wayBillReceive.getTargetSortCenterName(), 148, 76);
font=new Font("黑体",Font.BOLD,16);
g2.setFont(font);
g2.drawString(wayBillReceive.getSlideNo()+"-"+wayBillReceive.getTargetTableTrolleyCode(), 176, 92); //目的站点
font=new Font("黑体",Font.PLAIN,13);
g2.setFont(font);
g2.drawString(wayBillReceive.getSiteName(), 33, 115); //路区
g2.drawString(wayBillReceive.getRoad(), 148, 115); //包裹序列
g2.drawString("1/1", 195, 115); //客户信息
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
g2.drawString("客", 15, 128);
g2.drawString("户", 15, 138);
g2.drawString("信", 15, 148);
g2.drawString("息", 15, 158); String address = wayBillReceive.getReceiveAddress();
int y = 128;
if(StringUtils.isNotBlank(address)&&address.length()<=15){
g2.drawString(address, 35, 128);
}
if(StringUtils.isNotBlank(address)&&address.length()>15&&address.length()<=30){
g2.drawString(address.substring(0,15), 35, 128);
g2.drawString(address.substring(15,address.length()), 35, 138);
y = 140;
}
if(StringUtils.isNotBlank(address)&&address.length()>30){
g2.drawString(address.substring(0,15), 35, 128);
g2.drawString(address.substring(15,30), 35, 138);
g2.drawString(address.substring(30,address.length()), 35, 148);
y = 150;
}
g2.drawString(wayBillReceive.getReceiveName()+" "+(wayBillReceive.getReceiveTel()==null?"":wayBillReceive.getReceiveTel())+" "+(wayBillReceive.getReceiveMobile()==null?"":wayBillReceive.getReceiveMobile()), 35, y+10);
y=0; //客户签字
g2.drawString("客户", 176,126 );
g2.drawString("签字", 176,136 ); //应收金额
g2.drawString("应收", 176,148 );
g2.drawString("金额", 176,158 );
font=new Font("黑体",Font.PLAIN,10);
g2.setFont(font);
g2.drawString("¥0.00元", 216,152 ); font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
//第一个方框下方日期
g2.drawString(DateUtils.format(new Date(), "yyyy-MM-dd"), 175, 170); //第二个框
//运单号
font=new Font("黑体",Font.PLAIN,13);
g2.setFont(font);
g2.drawString("运单号:"+wayBillReceive.getDeliveryId(), 90, 193); //客户信息
font=new Font("黑体",Font.PLAIN,8);
g2.setFont(font);
g2.drawString("收件信息:"+wayBillReceive.getReceiveName()+" "+(wayBillReceive.getReceiveTel()==null?"":wayBillReceive.getReceiveTel())+" "+(wayBillReceive.getReceiveMobile()==null?"":wayBillReceive.getReceiveMobile()), 13, 207); //运单号条形码
fileName = StringUtils.getUuid()+".png";
image = ImageIO.read(BarCodeUtil.generateBarCode(wayBillReceive.getDeliveryId(), filePath+fileName));
g2.drawImage(image, 12, 209, 168, 36, this); //备注
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
y = 208;
String remark = "备注:"+(wayBillReceive.getRemark()==null?"":wayBillReceive.getRemark()); if(StringUtils.isNotBlank(remark)&&remark.length()<=10){
g2.drawString(remark, 184, y);
}
if(StringUtils.isNotBlank(remark)&&remark.length()>10&&remark.length()<=20){
g2.drawString(remark.substring(0,10), 184, y);
y = y+10;
g2.drawString(remark.substring(10,remark.length()), 184, y); }
if(StringUtils.isNotBlank(remark)&&remark.length()>20&&remark.length()<=30){
g2.drawString(remark.substring(0,10), 184, y);
y = y+10;
g2.drawString(remark.substring(10,20), 184, y);
y = y+10;
g2.drawString(remark.substring(20,remark.length()), 184, y);
}
y=0; //次日达、特会送
font=new Font("黑体",Font.BOLD,15);
g2.setFont(font);
g2.drawString((wayBillReceive.getAgingname()==null?"":wayBillReceive.getAgingname()), 25, 260);
g2.drawString("", 95, 260); //寄方信息
font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
g2.drawString("寄方信息:"+wayBillReceive.getSenderAddress(), 12, 272);
g2.drawString(wayBillReceive.getSenderName()+" "+(wayBillReceive.getSenderMobile()==null?"":wayBillReceive.getSenderMobile())+" "+(wayBillReceive.getSenderTel()==null?"":wayBillReceive.getSenderTel()), 12, 280); //商家ID、商家订单号
g2.drawString("商家ID:"+wayBillReceive.getCustomerCode(), 185, 272);
g2.drawString("B商家订单号:"+wayBillReceive.getOrderId(), 185, 279); //提示信息
font=new Font("黑体",Font.PLAIN,5);
g2.setFont(font);
g2.drawString("请您确认包裹完好,保留此包裹联时,代表您已经正常签收并确认外包裹完好", 12, 288);
g2.drawString("http://www.jdwl.com 客服电话:400-603-3600", 12, 293); //始发城市
font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
g2.drawString("始发城市:", 184, 292);
font=new Font("黑体",Font.PLAIN,10);
g2.setFont(font);
g2.drawString(wayBillReceive.getSendCity(), 214, 293); //最下方的打印日期
font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
g2.drawString(DateUtils.format(new Date(), "yyyy-MM-dd"), 183, 305);
g2.dispose();
} catch (Exception e) {
logger.info("打印快递单异常"+e);
} return Printable.PAGE_EXISTS;
} @Override
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
// TODO Auto-generated method stub
return false;
} public synchronized void print(WayBillReceive wbr,String fp){
wayBillReceive = wbr;
filePath = fp;
PrinterJob printerJob=PrinterJob.getPrinterJob(); Book book=new Book(); PageFormat pf = new PageFormat(); //pf.setOrientation(PageFormat.PORTRAIT); Paper p = new Paper(); //A4尺寸 590 x 840 p.setSize(280,317); p.setImageableArea(0,0, 280,317); //
// p.setSize(590,840);
//
// p.setImageableArea(12,12, 590,840); pf.setPaper(p); book.append(new Graphic(), pf); printerJob.setPageable(book); HashAttributeSet hs=new HashAttributeSet(); DocFlavor flavor = DocFlavor.BYTE_ARRAY.PNG; //HPRT PT562(USB) //HPRT PT541(USB) String printerName="HPRT HLP106S";
// String printerName="Canon iR2520 UFRII LT"; hs.add(new PrinterName(printerName, null)); PrintService[] pss = PrintServiceLookup.lookupPrintServices(flavor, hs); if(pss.length>0){ try { printerJob.setPrintService(pss[0]); printerJob.print(); } catch (PrinterException e) { logger.info("打印快递单异常"+e); } } } }
开发过程中不可能每画一部分或者需要调整字体大小都打印一张纸用来测试,因此可以用下面这段代码来实现预览
下面代码中drawLine方法的内容完全可以用上面第一个print方法的代码代替
package com.yutong.common.utils.print; import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.print.PageFormat;
import java.io.IOException;
import java.util.Date; import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants; import com.yutong.common.utils.DateUtils;
import com.yutong.common.utils.StringUtils; public class PrintView extends JPanel { public static void main(String[] args) {
/*
* 在 AWT 的事件队列线程中创建窗口和组件, 确保线程安全,
* 即 组件创建、绘制、事件响应 需要处于同一线程。
*/
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
// 创建窗口对象
MyFrame frame = new MyFrame();
// 显示窗口
frame.setVisible(true);
}
});
} /**
* 窗口
*/
public static class MyFrame extends JFrame { public static final String TITLE = "Java图形绘制"; public static final int WIDTH = 800;
public static final int HEIGHT = 450; public MyFrame() {
super();
initFrame();
} private void initFrame() {
// 设置 窗口标题 和 窗口大小
setTitle(TITLE);
setSize(WIDTH, HEIGHT); // 设置窗口关闭按钮的默认操作(点击关闭时退出进程)
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // 把窗口位置设置到屏幕的中心
setLocationRelativeTo(null); // 设置窗口的内容面板
MyPanel panel = new MyPanel(this);
setContentPane(panel);
} } /**
* 内容面板
*/
public static class MyPanel extends JPanel { private MyFrame frame; public MyPanel(MyFrame frame) {
super();
this.frame = frame;
} /**
* 绘制面板的内容: 创建 JPanel 后会调用一次该方法绘制内容,
* 之后如果数据改变需要重新绘制, 可调用 updateUI() 方法触发
* 系统再次调用该方法绘制更新 JPanel 的内容。
*/
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g); // 重新调用 Graphics 的绘制方法绘制时将自动擦除旧的内容 /* 自行打开下面注释查看各绘制效果 */ // 1. 线段 / 折线
drawLine(g); // 2. 矩形 / 多边形
// drawRect(g); // 3. 圆弧 / 扇形
// drawArc(g); // 4. 椭圆
// drawOval(g); // 5. 图片
// drawImage(g); // 6. 文本
// drawString(g);
} /**
* 1. 线段 / 折线
*/
private void drawLine(Graphics g) {
//获取画笔
Graphics2D g2=(Graphics2D) g.create(); //设置画笔颜色
g2.setPaint(Color.gray);
PageFormat pageFormat = new PageFormat();
g2.translate(pageFormat.getImageableX(),pageFormat.getImageableY()); Font font=new Font("黑体",Font.BOLD,36);
g2.setFont(font);
//外框 上9.6cm ,270px+10(外边距)
g2.drawLine(10, 10, 280, 10); //10
//外框 左5.4cm 151px+10(外边距)
g2.drawLine(10, 10, 10, 161);
//外框 下
g2.drawLine(10, 161, 280, 161);
//外框 右
g2.drawLine(280, 10, 280, 161); //中间第一横
g2.drawLine(10, 66, 280, 66); //56+10
//中间第二横
g2.drawLine(10, 100, 280, 100);//34+66 //中间第三横
g2.drawLine(10, 117, 280, 117);//17+100
//中间第四横
g2.drawLine(173, 139, 280, 139);//22+117 //中部第一条竖线
g2.drawLine(30, 100, 30, 161);
//中部第二条竖线
g2.drawLine(145, 66, 145, 117);
//中部第三条竖线
g2.drawLine(173, 100, 173, 161);
//中部第四条竖线
g2.drawLine(201, 117, 201, 161); //上半部分
//--------------------------------------------------------
//下半部分 //上
g2.drawLine(10, 179, 280,179); //179
//左
g2.drawLine(10, 179, 10, 299);
//下
g2.drawLine(10, 299, 280, 299);
//右
g2.drawLine(280,179, 280, 299); //中部第一条横线
g2.drawLine(10, 199, 280, 199); //20+179 //中部第二条横线
g2.drawLine(10, 245, 280, 245); //45+199 //中部第三条横线
g2.drawLine(10, 265, 280, 265); //20+245 //中部第四条横线
g2.drawLine(10, 282, 280, 282);//17+265 //中部第一条竖线
g2.drawLine(85, 245, 85, 265);
//中部第二条竖线
g2.drawLine(182, 199, 182, 299);
//中部第三条竖线
g2.drawLine(224, 245, 224, 265); g2.setPaint(Color.black); String fileName = StringUtils.getUuid()+".png";
try { font=new Font("黑体",Font.PLAIN,12);
g2.setFont(font);
g2.drawString("众", 268, 22); //包裹号条形码
Image image = ImageIO.read(BarCodeUtil.generateBarCode("JD20191211-1-1", "D://"+fileName));
g2.drawImage(image, 12, 12, 255, 52, this); font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
//重量
g2.drawString("0.5 KG", 220, 61); //始发地
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
g2.drawString("始发地:河南郑州", 13, 76);
font=new Font("黑体",Font.BOLD,20);
g2.setFont(font);
g2.drawString("23-CC-K", 40, 95); //目的地
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
g2.drawString("目的地:上海浦东", 148, 76);
font=new Font("黑体",Font.BOLD,20);
g2.setFont(font);
g2.drawString("6-K04", 176, 95); //目的站点
font=new Font("黑体",Font.PLAIN,13);
g2.setFont(font);
g2.drawString("G上海塘桥营业部", 33, 115); //路区
g2.drawString("84", 148, 115); //包裹序列
g2.drawString("包裹序列", 195, 115); //客户信息
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font);
g2.drawString("客", 15, 128);
g2.drawString("户", 15, 138);
g2.drawString("信", 15, 148);
g2.drawString("息", 15, 158); String address = "河南省郑州市郑东新区上河南省郑州市郑省郑州市";
int y = 128;
if(StringUtils.isNotBlank(address)&&address.length()<=15){
g2.drawString(address, 35, 128);
}
if(StringUtils.isNotBlank(address)&&address.length()>15&&address.length()<=30){
g2.drawString(address.substring(0,15), 35, 128);
g2.drawString(address.substring(15,address.length()), 35, 140);
y = 140;
}
if(StringUtils.isNotBlank(address)&&address.length()>30){
g2.drawString(address.substring(0,15), 35, 128);
g2.drawString(address.substring(15,30), 35, 140);
g2.drawString(address.substring(30,address.length()), 35, 150);
y = 150;
}
g2.drawString("小哪吒 15613223333", 35, y+10);
y=0; //客户签字
g2.drawString("客户", 176,126 );
g2.drawString("签字", 176,136 ); //应收金额
g2.drawString("应收", 176,148 );
g2.drawString("金额", 176,158 );
font=new Font("黑体",Font.PLAIN,10);
g2.setFont(font);
g2.drawString("¥8元", 216,152 ); font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
//第一个方框下方日期
g2.drawString(DateUtils.format(new Date(), "yyyy-MM-dd"), 175, 170); //第二个框
//运单号
font=new Font("黑体",Font.PLAIN,13);
g2.setFont(font);
g2.drawString("运单号:JD20191211", 75, 193); //客户信息
font=new Font("黑体",Font.PLAIN,8);
g2.setFont(font);
g2.drawString("收件信息:小哪吒 15612312215", 13, 207); //运单号条形码
fileName = StringUtils.getUuid()+".png";
image = ImageIO.read(BarCodeUtil.generateBarCode("JD20191211", "D://"+fileName));
g2.drawImage(image, 12, 209, 168, 36, this); //备注
font=new Font("黑体",Font.PLAIN,9);
g2.setFont(font); y = 208;
String remark = "备注:"+"热力裤为了任务了了离开的苟富贵丰东接口健康快乐"; if(StringUtils.isNotBlank(remark)&&remark.length()<=10){
g2.drawString(remark, 184, y);
}
if(StringUtils.isNotBlank(remark)&&remark.length()>10&&remark.length()<=20){
g2.drawString(remark.substring(0,10), 184, y);
y = y+10;
g2.drawString(remark.substring(10,remark.length()), 184, y); }
if(StringUtils.isNotBlank(remark)&&remark.length()>20&&remark.length()<=30){
g2.drawString(remark.substring(0,10), 184, y);
y = y+10;
g2.drawString(remark.substring(10,20), 184, y);
y = y+10;
g2.drawString(remark.substring(20,remark.length()), 184, y);
}
y=0; //次日达、特会送
font=new Font("黑体",Font.BOLD,15);
g2.setFont(font);
g2.drawString("次日达", 25, 260);
g2.drawString("特惠送", 95, 260); //寄方信息
font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
g2.drawString("寄方信息:河南省郑州市中原区西流湖小河边", 12, 272);
g2.drawString("小敖丙 18956562321", 12, 280); //商家ID、商家订单号
g2.drawString("商家ID:021K56554545", 185, 272);
g2.drawString("B商家订单号:8965466", 185, 279); //提示信息
font=new Font("黑体",Font.PLAIN,5);
g2.setFont(font);
g2.drawString("请您确认包裹完好,保留此包裹联时,代表您已经正常签收并确认外包裹完好", 12, 288);
g2.drawString("http://www.jdwl.com 客服电话:400-603-3600", 12, 293); //始发城市
font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
g2.drawString("始发城市:", 184, 292);
font=new Font("黑体",Font.PLAIN,10);
g2.setFont(font);
g2.drawString("郑州市", 214, 293); //最下方的打印日期
font=new Font("黑体",Font.PLAIN,6);
g2.setFont(font);
g2.drawString(DateUtils.format(new Date(), "yyyy-MM-dd"), 183, 305); } catch (IOException e) {
// TODO Auto-generated catch blo
e.printStackTrace();
} g2.dispose();
}
} }
java生成快递单并调用打印机打印的更多相关文章
- Java jacob调用打印机打印word文档
前面说了Java如何生成复杂的Word文档,今年记录下Java如何调用打印机打印word文档. 起初用的是自带的PrintJob,但是系统提供的打印机制并不成熟完整.网上的代码也是千篇一律,在我的打印 ...
- C# 调用打印机打印文件
C# 调用打印机打印文件,通常情况下,例如Word.Excel.PDF等可以使用一些对应的组件进行打印,另一个通用的方式是直接启用一个打印的进程进行打印.示例代码如下: using System.Di ...
- aspose调用打印机打印文档
aspose很不错的插件,功能非常强大,用到了其中的aspose.word. 如何生成word文档,点击. 下面说说如何如何通过打印机打印文档. aspose提供了一个print方法,通过该方法可以直 ...
- java 调用打印机 打印服务
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import javax ...
- Java调用打印机打印指定路径图片
依赖 javax.print package com.xgt.util; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; ...
- Java生成 Word文档的并打印解决方案
户要求用程序生成标准的word文档,要能打印,而且不能变形,以前用过很多解决方案,都在客户严格要求下牺牲的无比惨烈. POI读word文档还行,写文档实在不敢恭维,复杂的样式很难控制不提,想象一下一个 ...
- C# 调用打印机 打印 Excel
打印 Excel 模板 大体思路,通过NPOI操作Excel文件,通过Spire将Excel转成图片,将图片传给系统打印. Spire是收费工具,在微软库中下载Free版本. #region 打印所用 ...
- js调用打印机打印
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js调用打印机 打印整体或部分
有时前端的项目中需要添加打印的功能,首先要知道打印分为整体打印和局部打印两种,而局部打印又可细分为局部打印指定的部分,和局部打印指定部分之外的部分.实例比文字看起来更清晰,下面我将用代码来描述 1.整 ...
随机推荐
- [CSP-S模拟测试]:引子(大模拟)
题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...
- Sultana后记:纯css也能写col,select,datepicker,carousel...
未完待续 背景 如今css3越来越发达,focus-within等属性也已经开始在Chrome得到支持.如果有出色的css功底,一点点ps技能,你也能用css3配合原生html标签写出优秀的框架.通过 ...
- java 将数据库中的每一条数据取出放入数组或者List中
1.如何将数据库中数据按照行(即一整条数据)取出来,存入到数组当中? public static String str = null; // 将StringBuffer转化成字符串 public st ...
- vue-lazyload 图片不更新
前几天在用vue写项目的时候,因为图片比较多,所以采用了懒加载插件 vue-lazyload github:https://github.com/hilongjw/vue-lazyload#readm ...
- VS code 同步设置与插件
准备工作:拥有一个github账户,电脑上需安装VSCode.实现同步的功能主要依赖于VSCode插件 "Settings Sync"第一步:安装同步插件Settings Sync ...
- 深入理解Redis的持久化机制和原理
Redis是一种面向“key-value”类型数据的分布式NoSQL数据库系统,具有高性能.持久存储.适应高并发应用场景等优势.它虽然起步较晚,但发展却十分迅速. 近日,Redis的作者在博客中写到, ...
- RESTful再理解
目录 目录 前言 RESTful的目的 REST的含义 表现层 状态转化 无状态协议HTTP 最后 前言 这是在经过一段时间的积累后,对RESTFul框架的再一次更深入的理解.希望能够将零散的知识点连 ...
- RSA - 原理、特点(加解密及签名验签)及公钥和私钥的生成
Wiki - RSA加密演算法 Wiki - 欧拉函数 Wiki - 模反元素 ASN.1 格式标准 RSA算法原理(二) 注意: RSA 加密或签名后的结果是不可读的二进制,使用时经常会转为 BAS ...
- 让Debian以root登录
Debian默认不允许root登录,所以修改之. (1)让Debian以root登录 修改gdm3的登录pam文件 #vi /etc/pam.d/gdm3 将auth required pam_suc ...
- Spring切面编程之AOP
AOP 是OOP 的延续,是Aspect Oriented Programming 的缩写,意思是面向切面编程.可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种 ...