我是指调用IE把html显示出来,而不是把源代码答应出来。。

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ page import="org.w3c.dom.*" %>
    <%@ page import="javax.xml.parsers.*"%>
    <%@ page import="javax.xml.transform.*"%>
    <%@ page import="javax.xml.transform.stream.*"%>
    <%
        String l_sShow;//xml文档
          StringReader reader=new StringReader(l_sShow);
          StreamSource xml = new StreamSource(reader);
          StreamSource xsl = new StreamSource(xsl文件路径);
    //response.setContentType("text/html; charset=UTF-8");
           StreamResult result = new StreamResult(out);       Transformer trans = TransformerFactory.newInstance().newTransformer(xsl);
          //java.util.Properties properties = trans.getOutputProperties();
          //trans.setOutputProperty(OutputKeys.ENCODING,"GB2312");
          trans.setOutputProperty(OutputKeys.METHOD,"html");
          trans.setOutputProperty(OutputKeys.VERSION,"4.0");       
           //trans.setOutputProperty("encoding","UTF-8");
           trans.transform(xml, result);  
    %>
      

  2.   

    可以直接要在浏览器里显示xml文档,只需给xml文档加一个ProcessingInstrutiont就好了.
    Document doc=new Document();
    doc.createProcessingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"unicode.xsl\"");如果用javax.xml.transform包的话,你还需要xalan。