代码之家  ›  专栏  ›  技术社区  ›  Igor Konoplyanko

Java响应内容返回,而不是<or>&lt&燃气轮机;

  •  2
  • Igor Konoplyanko  · 技术社区  · 16 年前


    但也出现了html替换:of > 到 &gt; 等
    我该怎么做才能把这个替换掉?

    res.setHeader( "Cache-Control", "must-revalidate, post-check=0, pre-check=0" );
    res.setHeader( "Pragma", "public" );
    res.setContentType( "text/html" );
    

    短暂性脑缺血发作

    更新

    //    import com.ibm.useful.http.PostData;
            PostData pd = new PostData( req );
            final FileData data;
    
        try {
            data = pd.getFileData( "sqlFile" );
    
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        for ( byte b : data.getByteData() ) {
           buf.write( b );
        }
        res.getWriter().print( buf.toString() );
    }
    

    buf.toString() 通过调试器。那里没问题。替代更进一步。但是在哪里。。。

    3 回复  |  直到 16 年前
        1
  •  2
  •   BalusC    16 年前

    HTML特殊字符被转义到 HTML entities .

    如果你是 当然 web.xml 并调整 url-pattern

        2
  •  0
  •   Kennet    16 年前

    这通常发生在html字符(

    <,>,”

    尝试将escape设置为false或类似。 找不到“com.ibm.usful.http.PostData”的api文档

        3
  •  0
  •   Ravi Gupta    16 年前

    尝试使用以下代码段:

    res.setContentType("text/html; charset=UTF-8");
    

    如果这不能解决问题,请阅读此内容 article .