如何将xml和xsl转换之后,用System.out.print输出? 我是指调用IE把html显示出来,而不是把源代码答应出来。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ 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); %> 可以直接要在浏览器里显示xml文档,只需给xml文档加一个ProcessingInstrutiont就好了.Document doc=new Document();doc.createProcessingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"unicode.xsl\"");如果用javax.xml.transform包的话,你还需要xalan。 myeclipse里面怎么不能run as->run on server 呢? struts2 包继承的问题 tomcat启动时候的错误 struts1.x如何讲保存到数据库中的图片显示到页面? J2EE所用到的各种文档下载 JSP文件无法使用beans 请教要求支持10000并发用户访问的服务器配置方案?? 刚学EJB,求一简单在Jbuider环境下开发的例子,客户端是一jsp文件,有方法调用 哪里可以下载WebLogic7? 大家帮忙看看!一个关于J2EE的问题!!在县等待!! 关于struts开发的几个问题 如何用程序将resultset 与jdbtable组件绑定????
<%@ 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);
%>
Document doc=new Document();
doc.createProcessingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"unicode.xsl\"");如果用javax.xml.transform包的话,你还需要xalan。