项目的一个标签这样写到: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;
 }在页面对URL中的参数进行转换,请问为什么需要这样做?!是防止乱码吗?

解决方案 »

  1.   

    都命名成了  EncodeTag  然后又把每个字符转换成int值。还加上&#来做切断   我觉得。。是用来防止乱码的   转换成 int 数值后就不存在编码问题了 特别在用get方法传值上   哈哈哈  问问他吧
      

  2.   

    是普通的http地址拼接了
      sbuf.append("&#" + (int) chars[i]);但是这句话的意思我就不明白了!
             return SKIP_BODY;
      

  3.   

    作用跟把 < 变成 &lt; > 变成 &gt; 一样,为了把property忠实显示出来。