PDF默认是纵向打印的,通过rotate()来让其改变为横向打印,一般在打印A4 12*21纸以及发票的时候会用横向打印。横向打印时页面会出现行转列以及列转行的情况,因此在设置页面大小的时候一定要宽度设置的宽一些,表格的maxWidth设置在500到600之间就行了,不然会打印的表格就会不是太全或者很少。如果你是纵向打印,那么Rectangle设置页面大小就可以根据实际情况设置了。下面附上代码:

package com.ucfgroup.framework.web.app.company.service.process.pdf.pzPrint;

import java.io.File;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.ucfgroup.framework.utils.DateUtil;
import com.ucfgroup.framework.utils.NumberUtil;
import com.ucfgroup.framework.utils.Rmb;
import com.ucfgroup.framework.web.app.company.entity.CAccvouchAndDetail;
import com.ucfgroup.framework.web.app.company.entity.CUserZt;

public class PDFPrint {
Rectangle pageSize = new Rectangle(1000,730);
Document document = new Document(pageSize);// 建立一个Document对象

private static Font headfont;// 设置字体大小
private static Font keyfont;// 设置字体大小
private static Font textfont;// 设置字体大小
private static Font textfontHead;// 设置字体大小
private static int fm = 0;// 凭证号:记-后面的分母
private static int jcount = 0;// 凭证号:记-后面的分子
@SuppressWarnings("unused")
private static int pageNumber = 0;// 当前页
@SuppressWarnings("unused")
private static int totalPage = 0;// 总页数
private static int totalXhCount = 0;// 总共循环次数
BigDecimal totalJfh = BigDecimal.ZERO;//合计借方和
BigDecimal totalDfh = BigDecimal.ZERO;//合计贷方和
BigDecimal morepageTotalJF=BigDecimal.ZERO;//计算凭证分页时候的总和

static {
BaseFont bfChinese;
try {
bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
headfont = new Font(bfChinese, 19, Font.BOLD);// 设置字体大小
keyfont = new Font(bfChinese, 15, Font.BOLD);// 设置字体大小
textfont = new Font(bfChinese, 10, Font.NORMAL);// 设置字体大小
textfontHead = new Font(bfChinese, 11, Font.NORMAL);// 设置字体大小
} catch (Exception e) {
e.printStackTrace();
}
}

public PDFPrint(File file,int totalXhCountp,int pageNumberp,int totalPagep,int fmp ,int jcountp) {
totalXhCount = totalXhCountp;
pageNumber = pageNumberp;
fm = fmp;
jcount = jcountp;
document.setPageSize(pageSize.rotate());// 设置页面大小
document.setMargins(60, 50, 30, 10);
try {
PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
} catch (Exception e) {
e.printStackTrace();
}

}

int maxWidth = 630;

public PdfPCell createCell(String value, com.itextpdf.text.Font font, int align, int width) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setPhrase(new Phrase(value, font));
cell.setPaddingBottom(3);
cell.setPaddingTop(3);
// cell.setFixedHeight(35);
return cell;
}

public PdfPCell createCell(String value, com.itextpdf.text.Font font, int width) {
PdfPCell cell = new PdfPCell();
cell.setPhrase(new Phrase(value, font));
cell.setPaddingBottom(11);
cell.setPaddingTop(11);
// cell.setFixedHeight(35);
return cell;
}

public PdfPCell createCell(String value, com.itextpdf.text.Font font) {
PdfPCell cell = new PdfPCell();
cell.setPhrase(new Phrase(value, font));
cell.setPaddingBottom(11);
cell.setPaddingTop(11);
return cell;
}

public PdfPCell createCell(String value, com.itextpdf.text.Font font, int align, int colspan, boolean boderFlag,
int width) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(value, font));
cell.setPadding(3.0f);
if (!boderFlag) {
cell.setBorder(0);
// cell.setPaddingBottom(-50);
}
cell.setFixedHeight(30);
return cell;
}

public PdfPCell createCell(String value, com.itextpdf.text.Font font, int align, int colspan, boolean boderFlag) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(value, font));
cell.setPadding(3.0f);
if (!boderFlag) {
cell.setBorder(0);
}
cell.setFixedHeight(30);
if(value.contains("凭证号:记-")){
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
// cell.setPaddingLeft(-5);
}
return cell;
}

public PdfPCell createCell(String value, com.itextpdf.text.Font font, int align, int colspan, boolean boderFlag,
String flag) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_LEFT);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(value, font));
cell.setPadding(3.0f);
if (!boderFlag) {
cell.setBorder(0);
cell.setPaddingTop(15.0f);
cell.setPaddingBottom(8.0f);
}
cell.setPaddingTop(8);
cell.setPaddingLeft(-2);
if(flag.equals("3")){
cell.setPaddingLeft(-50);
}
if(flag.equals("4")){
cell.setPaddingLeft(-30);
}
return cell;
}

public PdfPTable createTable(int colNumber) {
PdfPTable table = new PdfPTable(colNumber);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}

public PdfPTable createTable(float[] widths) {
PdfPTable table = new PdfPTable(widths);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}

public PdfPTable createBlankTable() {
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setBorder(0);
table.addCell(createCell("", keyfont));
table.setSpacingAfter(20.0f);
table.setSpacingBefore(20.0f);
return table;
}

public void generatePDF(HttpServletRequest request, List<CAccvouchAndDetail> list) throws Exception {
int count = 0;
CUserZt zt = (CUserZt) request.getSession().getAttribute("ZTModel");
BigDecimal total = BigDecimal.ZERO;
BigDecimal totalJf = BigDecimal.ZERO;
BigDecimal totalDf = BigDecimal.ZERO;
int caccno = list.get(0).getCaccno();
String caccnoStr = "" + caccno;
if (caccno < 10) {
caccnoStr = "00" + caccno;
}
if (caccno >= 10 && caccno < 100) {
caccnoStr = "0" + caccno;
}
if (fm > 1) {
caccnoStr += "-" + jcount + "/" + fm;
}
PdfPTable table = createTable(4);
table.setWidths(new float[] { 0.22f, 0.42f, 0.18f, 0.18f });// 每个单元格占多宽

PdfPCell createCellp = createCell("yyyy", headfont, Element.ALIGN_CENTER, 1, false, 258);
createCellp.setPaddingLeft(25);

table.addCell(createCell("", headfont, Element.ALIGN_CENTER, 1, false, 202));
table.addCell(createCellp);
table.addCell(createCell("", headfont, Element.ALIGN_CENTER, 1, false, 115));
table.addCell(createCell("附单据数:" + list.get(0).getcFj(), keyfont, Element.ALIGN_RIGHT, 1, false, 115));

table.addCell(createCell(zt.getZtname(), textfontHead, Element.ALIGN_LEFT, 1, false));
table.addCell(createCell("日期:" + DateUtil.dateToString(list.get(0).getCdate(), "yyyy-MM-dd"), textfontHead,
Element.ALIGN_CENTER, 1, false));
// table.addCell(createCell(" ", textfontHead, Element.ALIGN_CENTER, 1, false));
PdfPCell caccnoCell = createCell("凭证号:记-" + caccnoStr, textfontHead, Element.ALIGN_RIGHT, 2, false);
table.addCell(caccnoCell);

PdfPCell createDigestCell = createCell("摘要", keyfont, Element.ALIGN_CENTER, 202);
createDigestCell.setBorderWidthLeft(1.5f);
createDigestCell.setBorderWidthTop(1.5f);
createDigestCell.setBorderWidthBottom(1.5f);
createDigestCell.setFixedHeight(25);

PdfPCell createSubjectCell = createCell("科目名称", keyfont, Element.ALIGN_CENTER, 258);
createSubjectCell.setBorderWidthTop(1.5f);
createSubjectCell.setBorderWidthBottom(1.5f);
createSubjectCell.setFixedHeight(25);

PdfPCell createJfCell = createCell("借方", keyfont, Element.ALIGN_CENTER, 115);
createJfCell.setBorderWidthTop(1.5f);
createJfCell.setBorderWidthBottom(1.5f);
createJfCell.setFixedHeight(25);

PdfPCell createDfCell = createCell("贷方", keyfont, Element.ALIGN_CENTER, 115);
createDfCell.setBorderWidthTop(1.5f);
createDfCell.setBorderWidthBottom(1.5f);
createDfCell.setBorderWidthRight(1.5f);
createDfCell.setFixedHeight(25);

table.addCell(createDigestCell);
table.addCell(createSubjectCell);
table.addCell(createJfCell);
table.addCell(createDfCell);

for (CAccvouchAndDetail cAccvouchAndDetail : list) {
PdfPCell createDigestTextLeftCell = createCell(cAccvouchAndDetail.getCdigest(), textfont, 202);
createDigestTextLeftCell.setBorderWidthLeft(1.5f);

table.addCell(createDigestTextLeftCell);
table.addCell(createCell(cAccvouchAndDetail.getCcodename(), textfont, 258));

PdfPCell createCellj = createCell(judgeMoney(cAccvouchAndDetail.getcJf()), textfont, 115);
createCellj.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellj.setHorizontalAlignment(Element.ALIGN_RIGHT);

PdfPCell createCelld = createCell(judgeMoney(cAccvouchAndDetail.getcDf()), textfont, 115);
createCelld.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCelld.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCelld.setBorderWidthRight(1.5f);

table.addCell(createCellj);
table.addCell(createCelld);
total = total.add(cAccvouchAndDetail.getcJf() == null ? BigDecimal.ZERO : cAccvouchAndDetail.getcJf());
totalJf = totalJf.add(cAccvouchAndDetail.getcJf() == null ? BigDecimal.ZERO : cAccvouchAndDetail.getcJf());//借方合计 ---
totalDf = totalDf.add(cAccvouchAndDetail.getcDf() == null ? BigDecimal.ZERO : cAccvouchAndDetail.getcDf());//贷方合计 ---
count += 1;
}
//借方和贷方和的累加 --
for(;totalXhCount<jcount;){
totalJfh = totalJfh.add(totalJf);
totalDfh = totalDfh.add(totalDf);
break;
}
for (int i = count + 1; i < 6; i++) {
PdfPCell leftBlankCell = createCell(" ", textfont, 202);
leftBlankCell.setBorderWidthLeft(1.5f);
table.addCell(leftBlankCell);
table.addCell(createCell(" ", textfont, 258));
table.addCell(createCell(" ", textfont, 115));
PdfPCell rightBlankCell = createCell(" ", textfont, 115);
rightBlankCell.setBorderWidthRight(1.5f);
table.addCell(rightBlankCell);
}

if (total.compareTo(BigDecimal.ZERO) != 0||
totalJf.compareTo(BigDecimal.ZERO) != 0 ||
totalDf.compareTo(BigDecimal.ZERO) != 0) {
if(jcount > 0 && jcount < fm ){//当凭证为多页
PdfPCell createCelln = createCell("合计:", textfontHead, Element.ALIGN_RIGHT);
createCelln.setColspan(2);
createCelln.setPaddingLeft(4);
createCelln.setPaddingBottom(0);
createCelln.setPaddingTop(0);
createCelln.setFixedHeight(17);
createCelln.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCelln.setBorderWidthLeft(1.5f);
createCelln.setBorderWidthTop(1.5f);
createCelln.setBorderWidthBottom(1.5f);
table.addCell(createCelln);
//添加借方金额到表格
PdfPCell createCellJf = createCell(judgeMoney(totalJf), textfontHead,115);
createCellJf.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellJf.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCellJf.setBorderWidthTop(1.5f);
createCellJf.setBorderWidthBottom(1.5f);

table.addCell(createCellJf);

//添加贷方金额到表格
PdfPCell createCellDf = createCell(judgeMoney(totalDf), textfontHead,115);
createCellDf.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellDf.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCellDf.setBorderWidthRight(1.5f);
createCellDf.setBorderWidthTop(1.5f);
createCellDf.setBorderWidthBottom(1.5f);
table.addCell(createCellDf);
}
if(jcount == fm ){//当凭证为最后一页时

PdfPCell createCell = createCell("合计:" + Rmb.CmycurD(morepageTotalJF.toString()), textfont,
Element.ALIGN_LEFT);
createCell.setColspan(2);
createCell.setPaddingLeft(4);
createCell.setPaddingBottom(0);
createCell.setPaddingTop(0);
createCell.setFixedHeight(17);
createCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCell.setBorderWidthLeft(1.5f);
createCell.setBorderWidthTop(1.5f);
createCell.setBorderWidthBottom(1.5f);
table.addCell(createCell);

PdfPCell createCellJfs = createCell(judgeMoney(morepageTotalJF), textfont,115);
createCellJfs.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellJfs.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCellJfs.setBorderWidthTop(1.5f);
createCellJfs.setBorderWidthBottom(1.5f);

table.addCell(createCellJfs);

PdfPCell createCellDfs = createCell(judgeMoney(morepageTotalJF), textfont,115);
createCellDfs.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellDfs.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCellDfs.setBorderWidthRight(1.5f);
createCellDfs.setBorderWidthTop(1.5f);
createCellDfs.setBorderWidthBottom(1.5f);

table.addCell(createCellDfs);

morepageTotalJF=BigDecimal.ZERO;//清除上次的凭证分页金额总和
}
if (jcount == 0 && fm == 1) {//当凭证只有一页
PdfPCell createCell = createCell("合计:" + Rmb.CmycurD(total.toString()), textfont, Element.ALIGN_LEFT);
createCell.setColspan(2);
createCell.setPaddingLeft(4);
createCell.setPaddingBottom(0);
createCell.setPaddingTop(0);
createCell.setFixedHeight(17);
createCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCell.setBorderWidthLeft(1.5f);
createCell.setBorderWidthTop(1.5f);
createCell.setBorderWidthBottom(1.5f);
table.addCell(createCell);

PdfPCell createCellJf = createCell(judgeMoney(totalJf), textfont,115);
createCellJf.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellJf.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCellJf.setBorderWidthTop(1.5f);
createCellJf.setBorderWidthBottom(1.5f);

table.addCell(createCellJf);

PdfPCell createCellDf = createCell(judgeMoney(totalDf), textfont,115);
createCellDf.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCellDf.setHorizontalAlignment(Element.ALIGN_RIGHT);
createCellDf.setBorderWidthTop(1.5f);
createCellDf.setBorderWidthBottom(1.5f);
createCellDf.setBorderWidthRight(1.5f);

table.addCell(createCellDf);
}
} else {
PdfPCell createCell = createCell("合计:", textfont, Element.ALIGN_LEFT);
createCell.setColspan(2);
createCell.setPaddingLeft(4);
createCell.setPaddingBottom(0);
createCell.setPaddingTop(0);
createCell.setFixedHeight(17);
createCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
createCell.setBorderWidthTop(1.5f);
createCell.setBorderWidthBottom(1.5f);
createCell.setBorderWidthLeft(1.5f);
table.addCell(createCell);

table.addCell(createCell(" ", keyfont, Element.ALIGN_CENTER,115));
PdfPCell createSumCell = createCell(" ", keyfont, Element.ALIGN_CENTER,115);
table.addCell(createSumCell);
createSumCell.setBorderWidthTop(1.5f);
createSumCell.setBorderWidthBottom(1.5f);
createSumCell.setBorderWidthRight(1.5f);
}

String shrName = zt.getShrName() == null ? "" : zt.getShrName();
String zdrName = zt.getZdrName() == null ? "" : zt.getZdrName();
String zgrName = zt.getZgName() == null ? "" : zt.getZgName();

table.addCell(createCell("xxxx:" + zdrName, textfont, Element.ALIGN_LEFT, 1, false, "1"));
table.addCell(createCell("xxxx:", textfont, Element.ALIGN_LEFT, 1, false, "2"));
table.addCell(createCell("xxxx:"+shrName, textfont, Element.ALIGN_LEFT, 1, false, "3"));
table.addCell(createCell("xxxx:" + zgrName, textfont, Element.ALIGN_LEFT, 1, false, "4"));

document.add(table);

// // 创建Chunk对象,设置下划线的厚度为1
// Chunk strike = new Chunk("");
// strike.setUnderline(1f, 3f);
// document.add(strike);
}

public void printPdf(HttpServletRequest request, Map<String,
List<CAccvouchAndDetail>> map, List<String> aidList,int
fmp,int jcountp)
throws Exception {
fm = fmp;
jcount = jcountp;
int mapSize = aidList.size();
int mapYs = mapSize % 2;
if (mapYs > 0) {
totalPage = mapSize / 2 + 1;
} else {
totalPage = mapSize / 2;
}
for (String aid : aidList) {
List<CAccvouchAndDetail> list = map.get(aid);
Map<Integer, List<CAccvouchAndDetail>> cfListMap = new HashMap<Integer, List<CAccvouchAndDetail>>();
int size = list.size();
int cs = size / 5;
int ys = size % 5;
if (cs > 1) {
if (ys > 0) {
fm = cs + 1;
} else {
fm = cs;
}
}
if (cs == 1 && ys > 0) {
fm = 2;
}
if (size > 5) {
int count = 0;
int jsq = 0;// 计数器
for (CAccvouchAndDetail cAccvouchAndDetail : list) {
morepageTotalJF = morepageTotalJF.add(cAccvouchAndDetail.getcJf());
List<CAccvouchAndDetail> tempList = cfListMap.get(count);
if (null == tempList || jsq == 5) {
jsq = 0;
tempList = new ArrayList<CAccvouchAndDetail>();
tempList.add(cAccvouchAndDetail);
count += 1;
cfListMap.put(count, tempList);
jsq += 1;
} else {
tempList.add(cAccvouchAndDetail);
jsq += 1;
}
}
jcount = 0;
for (int i = 0; i < fm; i++) {
List<CAccvouchAndDetail> cfList = cfListMap.get(i + 1);
jcount += 1;
generatePDF(request, cfList);
document.newPage();
totalXhCount += 1;
}
} else {
fm = 1;
jcount = 0;
generatePDF(request, list);
document.newPage();
totalXhCount += 1;
}

}
document.close();
}

public static String leftPad(String str, int i) {
int addSpaceNo = i - str.length();
String space = "";
for (int k = 0; k < addSpaceNo; k++) {
space = " " + space;
}
;
String result = space + str;
return result;
}

private String judgeMoney(BigDecimal bd) {
String temp = "";
if(bd != null && bd.compareTo(BigDecimal.ZERO) != 0){
temp = NumberUtil.msStrAddComma(NumberUtil.msBigDecimalFormat(bd));
}
return temp;
}
}

java的PDF纵横向打印的更多相关文章

  1. JAVA导出pdf实例

    一.直接导出成PDF   Java代码 1. import java.io.FileNotFoundException; 2. import java.io.FileOutputStream; 3.  ...

  2. itextpdf JAVA 输出PDF文档

    使用JAVA生成PDF的时候,还是有些注意事项需要处理的. 第一.中文问题,默认的itext是不支持中文的,想要支持,需要做些处理. 1.直接引用操作系统的中文字体库支持,由于此方案限制性强,又绑定了 ...

  3. Java IO(Properties/对象序列化/打印流/commons-io)

    Java IO(Properties/对象序列化/打印流/commons-io) Properties Properties 类表示了一个持久的属性集.Properties 可保存在流中或从流中加载. ...

  4. 转 Java操作PDF之iText详细入门

    转 Java操作PDF之iText详细入门 2016年08月08日 11:06:00 阅读数:19490 iText是著名的开放项目,是用于生成PDF文档的一个java类库.通过iText不仅可以生成 ...

  5. java根据pdf模版动态生成pdf

    java根据pdf模版动态生成pdf package com.utils; import java.io.ByteArrayOutputStream; import java.io.File; imp ...

  6. java里如何实现循环打印出字符或字符数组里的内容

    不多说,直接上干货! java里如何实现循环打印出字符里的内容 没写,暂时不会 java里如何实现循环打印出字符数组里的内容 public class test { public static voi ...

  7. java里如何实现循环打印出字符串或字符串数组里的内容

    不多说,直接上干货! java里如何实现循环打印出字符串里的内容 思路:可以先将字符串转换成字符串数组. public class test { public static void main(Str ...

  8. 个人永久性免费-Excel催化剂功能第50波-批量打印、导出PDF、双面打印功能

    在倡导无纸化办公的今天,是否打印是一个碍眼的功能呢,某些时候的确是,但对于数据的留存,在现在鼓吹区块链技术的今天,仍然不失它的核心价值,数据报表.单据打印出来留存,仍然是一种不可或缺的数据存档和防篡改 ...

  9. java生成二维码打印到浏览器

    java生成二维码打印到浏览器   解决方法: pom.xml的依赖两个jar包: <!-- https://mvnrepository.com/artifact/com.google.zxin ...

随机推荐

  1. ubuntu 16.04 LTS 安装 teamviewer 13

    背景介绍 由于需要做现场的远程支持,经协商后在现场的服务器上安装TeamViewer 以便后续操作. 本来以为很简单的一件事,谁知却稍微费了一番周折  :( 记录下来,希望提醒自己的同时也希望能够帮到 ...

  2. Python 编程规范梳理

    缘由 由于项目团队中新加入了几名攻城狮, 大家之前的背景各不相同,写出的代码也是“风格迥异”.正所谓:“无规则不成方圆”,因此需要对编程进行必要的规范. 整体的思路是:依照PEP8 Python 编码 ...

  3. golang web框架 beego 学习 (三) beego获取参数

    直接上常用的例子吧: A:     获取URL中的参数 router func init() { beego.Router("/task/?:id/?:name", &co ...

  4. javaScript语言的预编译与运行

    JS代码执行的过程: 1.预编译 ---- 事先对js代码做一个预处理 2.代码运行---开始执行JS代码. JS编程: 1.加载DOM的最好在/BODY之前 2.与DOM渲染无关的放在Head里面 ...

  5. 如何决定Web应用的线程池大小

    线程池(Thread Pool)在Web应用中线程池的大小决定了在任何一个时间点应用可以处理请求的并发数.如果一个系统收到的请求数超过了线程池的大小,那么超出的请求要么进入等待队列要么被拒绝.请注意, ...

  6. Mac OS 修改hosts文件

    这里用得是 VI 编辑器修改 打开终端(应用程序——实用工具),运行: sudo vi /etc/hosts,此时屏幕上会提示你输入密码 打开 hosts 文件之后按 i 键进入插入模式(可理解为编辑 ...

  7. python写批量weblogic爆破脚本

    前言: 整理笔记的时候,发现了weblogic的攻击方法.心里打着算盘看看怎么写 个批量的弱口令爆破脚本.得出了以下思路 思路: 1.利用钟馗之眼采集weblogic的网站,将IP写入到txt 2.添 ...

  8. 《opencv学习》 之 特征检测与匹配

    这几天学习SURF特征检测,直接看的视频和书本有点吃不消,现在是基本看懂了,如果写博客记录没有必要,因为网上都差不多,笔记都在书上了,以下是个人认为比较浅显易懂的文章,当然海有很多好文章我没看到. 看 ...

  9. opencv小问题大智慧

    opencv易错点记录 1. 判断条件不应使用CV_ASSERT(),而使用CV_Assert(). 2.  用下面这个自适应阈值必须进行数据的转换,不能直接传入数据!不然程序一直崩溃,找了很久才发现 ...

  10. svn+apache+ssl快速部署

    在svn+apache文章中已经成功搭建了web-svn,由于在http网络上数据都是以明文传输,公司的源码需要一定的保密机制,基于安全考虑现整合web-svn+ssl.构建安全的svn服务器, 1. ...