documenttag.java
来自「源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网」· Java 代码 · 共 72 行
JAVA
72 行
package cn.js.fan.module.cms;
import javax.servlet.jsp.tagext.*;
import cn.js.fan.db.ResultRecord;
import org.apache.log4j.Logger;
import cn.js.fan.db.ResultIterator;
import cn.js.fan.util.StrUtil;
import cn.js.fan.web.SkinUtil;
public class DocumentTag extends BodyTagSupport {
int id = -1;
String dirCode = "";
Logger logger = Logger.getLogger(DocumentTag.class.getName());
public DocumentTag() {
}
public void setId(String strid) {
this.id = Integer.parseInt(strid);
}
public void setDirCode(String d) {
this.dirCode = d;
}
/**
* put your documentation comment here
* @return
*/
public int doEndTag() {
try {
Document doc = null;
if (id != -1) {
doc = getDoc(id);
} else if (!dirCode.equals("")) {
Leaf leaf = new Leaf();
leaf = leaf.getLeaf(dirCode);
//logger.info("dirCode=" + dirCode);
if (leaf != null && leaf.getType() == 1)
doc = getDoc(leaf.getDocID());
}
if (doc != null) {
BodyContent bc = getBodyContent();
String body = bc.getString();
//logger.info("content=" + doc.getContent());
body = body.replaceAll("\\$title", doc.getTitle());
body = body.replaceAll("\\$id", "" + doc.getID());
body = body.replaceAll("\\$modifiedDate", cn.js.fan.util.DateUtil.format(doc.getModifiedDate(), "yy-MM-dd"));
body = body.replaceAll("\\$summary", doc.getSummary());
body = body.replaceAll("\\$content", doc.getContent(1));
body = body.replaceAll("\\$dirCode", doc.getDirCode());
body = body.replaceAll("\\@dirCode", StrUtil.UrlEncode(doc.getDirCode()));
pageContext.getOut().print(body);
} else {
pageContext.getOut().print("Document not found!");
}
} catch (Exception e) {
logger.error(e.getMessage());
}
return EVAL_PAGE;
}
public Document getDoc(int id) {
DocumentMgr docmgr = new DocumentMgr();
Document doc = docmgr.getDocument(id);
return doc;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?