encodehtmltag.java

来自「大家好啊 快来抢购J2ME东东 挺不错的啊 不要后悔啊 抓住机会」· Java 代码 · 共 32 行

JAVA
32
字号
package com.ora.jsp.tags.generic;

import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import com.ora.jsp.util.*;

/**
 * This class is a tag handler for custom action that replaces
 * HTML special characters in its body with the corresponding
 * HTML character entities.
 *
 * @author Hans Bergsten, Gefion software <hans@gefionsoftware.com>
 * @version 1.0
 */
public class EncodeHTMLTag extends BodyTagSupport {
    
    /**
     * Reads the body content, converts all HTML special characters
     * with the corresponding HTML character entities, and adds the
     * result to the response body.
     */
    public int doAfterBody() throws JspException {
        BodyContent bc = getBodyContent();
        JspWriter out = getPreviousOut();
        try {
            out.write(StringFormat.toHTMLString(bc.getString()));
        }
        catch (IOException e) {} // Ignore
        return SKIP_BODY;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?