📄 valueresulttag.java
字号:
package com.trulytech.mantis.tag;
import java.io.*;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import com.trulytech.mantis.result.*;
/**
*
* <p>Title: Mantis</p>
*
* <p>Description: 根据给定的列值获得DBResult中的值</p>
*
* <p>Copyright: Copyright (c) 2002</p>
*
* <p>Company: </p>
*
* @author Wang Xian
* @version 1.0
*/
/*例如********************************************************
<bean:get name="Result" col="0" />
<bean:get name="Result" col="0" row="1"/>
<bean:get name="Result" col="0" row="1" type="html"/>
*/
public class ValueResultTag
extends TagSupport {
//行数
private int Col = 0;
//列数
private int Row = 0;
//输出格式
private String Type = "";
//request中DBResult的值
private String name = null;
/**
* 覆盖doStartTag方法
* @return int
* @throws JspTagException
*/
public int doStartTag() throws JspTagException {
return EVAL_BODY_INCLUDE;
}
public void setCol(int Col) {
this.Col = Col;
}
public void setName(String name) {
this.name = name;
}
public void setRow(int Row) {
this.Row = Row;
}
public void setType(String Type) {
if (Type == null)
this.Type = "";
else
this.Type = Type;
}
/**
* 结束tag
* @return int
* @throws JspTagException
*/
public int doEndTag() throws JspTagException {
try {
if (this.pageContext.findAttribute(name) != null) {
if (this.pageContext.findAttribute(name) instanceof DBResult) {
if ( ( (DBResult)this.pageContext.findAttribute(name)).ResultBuffer.
size() > Row) {
ArrayList rec = (ArrayList) ( ( (DBResult)this.pageContext.
findAttribute(name)).ResultBuffer).
get(Row);
if (Col >= rec.size())
this.pageContext.getOut().write("");
else
//如果是html输出
if (this.Type.equalsIgnoreCase("html"))
this.pageContext.getOut().write(com.trulytech.mantis.system.
Properties.HTMLEncoder( ( (
DBColumn) rec.get(Col)).Value));
//如果是普通输出
else
this.pageContext.getOut().write( ( (DBColumn) rec.get(Col)).Value);
}
else
this.pageContext.getOut().write("");
}
else
this.pageContext.getOut().write("");
}
else
this.pageContext.getOut().write("");
}
catch (IOException e) {
throw new JspTagException("Fatal error");
}
return EVAL_PAGE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -