📄 dynabeantag.java
字号:
package org.shaoye.customtag;
import java.util.Hashtable;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyContent;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import org.common.util.FormatUtil;
/**
* @author zhangt
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class DynaBeanTag extends BodyTagSupport{
protected String name;
protected String property;
protected String scope;
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Returns the property.
* @return String
*/
public String getProperty() {
return property;
}
/**
* Returns the scope.
* @return String
*/
public String getScope() {
return scope;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the property.
* @param property The property to set
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Sets the scope.
* @param scope The scope to set
*/
public void setScope(String scope) {
this.scope = scope;
}
/**
*
*
*
*/
//public int doStartTag() throws JspException
//{
//Object value =
//RequestUtils.lookup(pageContext, name, property, scope);
// return (SKIP_BODY);
//}
public int doEndTag() throws JspTagException
{
try
{ /* 2)得到标签中的文本 */
BodyContent l_tagbody = getBodyContent();
String ls_output = "";
/* 3)如果标签体有文本,就处理它 */
if(l_tagbody != null)
{
//HTML_Format l_format = new HTML_Format();
/* 3a) 将标签体的内容转换为一个字符串 */
String ls_html_text = l_tagbody.getString();
ls_output = FormatUtil.format(ls_html_text);//l_format.HTML_Encode(ls_html_text);
}
/* 4)将结果写回到数据流中 */
pageContext.getOut().write(ls_output.trim());
}
catch (IOException e)
{
throw new JspTagException("Tag Error:" + e.toString());
}
/* 让JSP继续处理以下页面的内容 */
return EVAL_PAGE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -