documenttag.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 66 行
JAVA
66 行
package cn.js.fan.module.cms;import javax.servlet.jsp.tagext.*;import org.apache.log4j.Logger;import cn.js.fan.util.StrUtil;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; } 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); if (leaf != null && leaf.getType() == 1) doc = getDoc(leaf.getDocID()); } if (doc != null) { BodyContent bc = getBodyContent(); String body = bc.getString(); 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 + -
显示快捷键?