JSP結合JavaBean生成靜態頁面示例
1
2
3
4
import java
import java
import java
publicclass JspToStaticHTMLTest {
public JspToStaticHTMLTest() {
}
String midStr;//中間生成的如文章的文字等
String fileName="demo
/**
*一個模板中的頭字符串
*@return
*/
private String getHeadStr() {
String s="<!DOCTYPE HTML PUBLIC "
""+
"<%@ page contentType="text/html;charset=GBK"%>n" +
"<%@ page import="palfinger
"<html>n" +
" <head>n" +
" <meta http
" <title>JSP加JAVA</title>n" +
" <script language="JavaScript
" </script>n" +
" </head>n" +
" <body>n" +
" <center>";
return s;
}
/**
*一個模板中的尾字符串
*@return
*/
private String getTailStr() {
String s=" </center>n" +
" </body>n" +
"</html>";
return s;
}
/**
*中間就是我們需要的
*@parammidStr
*/
publicvoid setMidStr(String midStr) {
this
}
/**
*取得中間動態生成的字符串
*@return
*/
private String getMidStr() {
returnmidStr;
}
/**
*整個字符串
*@return
*/
private String HTMLStr() {
String s=getHeadStr()+getMidStr()+getTailStr();
return s;
}
publicvoid setFileName(String fileName) {
this
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19991.html