日期:2014-05-19 浏览次数:20730 次
public class EncodeTag extends TagSupport { private String property; private Log logger = LogFactory.getLog(this.getClass()); public int doStartTag() throws JspException { logger.debug(property); if(property==null){ logger.debug("property is null"); property = ""; } StringBuffer sbuf = new StringBuffer(); char[] chars = property.toCharArray(); for (int i = 0; i < chars.length; i++) { sbuf.append("&#" + (int) chars[i]); } try{ pageContext.getOut().print(sbuf.toString()); } catch (IOException ex) { throw new JspException(ex.getMessage()); } return SKIP_BODY; }