❶ 《精通Spring2.xJavaWeb開發》pdf下載在線閱讀,求百度網盤雲資源
《精通Spring2.xJavaWeb開發》電子書網盤下載免費在線閱讀
鏈接:https://pan..com/s/1JmsGQWggP2MaSmDpEqyvQA
書名:精通Spring2.xJavaWeb開發
出版年份:2008-9
頁數:371
內容介紹:
《精通Spring 2.x Java Web開發》按照從易到難、由淺入深、循序漸進的順序介紹Spring,並使用大量的實例使讀者更加深刻地理解所學習的知識,更好地進行開發實踐。《精通Spring 2.x Java Web開發》深刻地揭示了Spring的技術內幕,對IOC、DI、AOP、事務管理等根基性的技術進行了深度的講解。讀者閱讀《精通Spring 2.x Java Web開發》後,不但可以熟練使用Spring的各項功能,而且還能夠對書中的實例舉一反三。
❷ 如何用Java實現Web伺服器
如何用Java實現Web伺服器 一、HTTP協議的作用原理
WWW是以Internet作為傳輸媒介的一個應用系統,WWW網上最基本的傳輸單位是Web網頁。WWW的工作基於客戶機/伺服器計算模型,由Web 瀏覽器(客戶機)和Web伺服器(伺服器)構成,兩者之間採用超文本傳送協議(HTTP)進行通信。HTTP協議是基於TCP/IP協議之上的協議,是Web瀏覽器和Web伺服器之間的應用層協議,是通用的、無狀態的、面向對象的協議。HTTP協議的作用原理包括四個步驟:
(1) 連接:Web瀏覽器與Web伺服器建立連接,打開一個稱為socket(套接字)的虛擬文件,此文件的建立標志著連接建立成功。
(2) 請求:Web瀏覽器通過socket向Web伺服器提交請求。HTTP的請求一般是GET或POST命令(POST用於FORM參數的傳遞)。GET命令的格式為:
GET 路徑/文件名 HTTP/1.0
文件名指出所訪問的文件,HTTP/1.0指出Web瀏覽器使用的HTTP版本。
(3) 應答:Web瀏覽器提交請求後,通過HTTP協議傳送給Web伺服器。Web伺服器接到後,進行事務處理,處理結果又通過HTTP傳回給Web瀏覽器,從而在Web瀏覽器上顯示出所請求的頁面。
❸ java如何實現在web工程中用OpenOffice生成帶有圖片水印的pdf
需要itext2.1.5,
以下是對pdf加水印的代碼,包括文字水印和圖片水印
public int fileCopy(String srcPath, String destPath) {
FileOutputStream fos = null;
FileInputStream fis = null;
try {
fos = new FileOutputStream(destPath);
fis = new FileInputStream(srcPath);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
return 1;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fis.close();
fos.flush();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return 0;
}
/**
* 為pdf文件加文字水印
*
* @param srcPath
* 源文件路徑
* @param destPath
* 目標文件路徑
* @param waterText
* 水印文字
* @throws DocumentException
* @throws IOException
*/
public void wordWaterMark(String srcPath, String destPath, String waterText) throws DocumentException, IOException {
int result = fileCopy(srcPath, destPath);
if (result == 1) {
// 待加水印的文件
PdfReader reader = new PdfReader(destPath);
// 加完水印的文件
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(srcPath));
int total = reader.getNumberOfPages() + 1;
PdfContentByte content;
// 設置字體
BaseFont base = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
// 水印文字
int j = waterText.length(); // 文字長度
char c = 0;
int high = 0;// 高度
// 循環對每頁插入水印
for (int i = 1; i < total; i++) {
// 水印的起始
high = 60;
content = stamper.getUnderContent(i);
PdfGState gs = new PdfGState();
gs.setFillOpacity(0.1f);// 設置透明度為0.2
content.setGState(gs);
// 開始
content.beginText();
// 設置顏色
// content.setColorFill(new Color());
// 設置字體及字型大小
content.setFontAndSize(base, 88);
// 設置起始位置
content.setTextMatrix(120, 333);
// 開始寫入水印
for (int k = 0; k < j; k++) {
content.setTextRise(high);
c = waterText.charAt(k);
content.showText(c + "");
high += 20;
}
content.endText();
}
stamper.close();
System.out.println("添加成功++++++++++++++++++++++++++++++++++++++++++");
} else {
System.out.println("復制pdf失敗====================");
}
}
public void picWaterMark(String srcPath, String destPath, String imageFilePath)
throws DocumentException, IOException {
int result = fileCopy(srcPath, destPath);
if (result == 1) {
// 待加水印的文件
PdfReader reader = new PdfReader(destPath);
// 加完水印的文件
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(srcPath));
Image img = Image.getInstance(imageFilePath);
img.setAbsolutePosition(50, 400);// 坐標
img.setRotation(20);// 旋轉 弧度
img.setRotationDegrees(45);// 旋轉 角度
// image.scaleAbsolute(200,100);//自定義大小
img.scalePercent(50);// 依照比例縮放
int pageSize = reader.getNumberOfPages();
for (int i = 1; i <= pageSize; i++) {
PdfContentByte under = stamper.getUnderContent(i);
under.addImage(img);
PdfGState gs = new PdfGState();
gs.setFillOpacity(0.2f);// 設置透明度為0.2
under.setGState(gs);
}
stamper.close();// 關閉
System.out.println("添加成功++++++++++++++++++++++++++++++++++++++++++");
} else {
System.out.println("復制pdf失敗====================");
}
}
linux下轉pdf可以用libreoffice,需要安裝,這個是免費的,具體代碼如下:
String command = "libreoffice5.0 --invisible --convert-to pdf:writer_pdf_Export --outdir " + destFilepath
+ " " + source;
try {
p = Runtime.getRuntime().exec(command);
p.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}