日期:2014-05-19  浏览次数:20601 次

在网页中嵌入经xsl编译后的xml
1.xml内容是通过程序生成,采用从数据库中获取的对话内容后拼接成xml内容,类型是一个字符串类型。
2.现在有一个xsl模板,能够对xml内容进行从新排版。
我想问的是我怎么才能在页面上显示这个xsl,框架使用了struts2

Java code

    public String searchSingle()throws Exception{
        
        //获取页面传来的参数
        Long comId = SessionUtil.getLoginCompanyId(request);
        String companyId  = comId.toString();
        Long opId = (long) 68361;
                //Long.parseLong(request.getParameter("operatorId"));
        Long msgId = (long) 47436604;
                //Long.parseLong(request.getParameter("msgId"));
        ChatInfoDTO queryResult = chatInfoService.getSingleChatInfo(msgId, opId);
        request.setAttribute("queryResult", queryResult);
        ArrayList<ChatContent> chatcontent = chatContentService.getChatContentByMsgId(msgId, companyId);
        @SuppressWarnings("deprecation")
//生成的xml内容
        String xmlXslFormtContent = ChatContentUtil.getXmlXslFormtContent(chatcontent, queryResult);
        System.out.println(xmlXslFormtContent);
        return "success";
    }



------解决方案--------------------
可以在action中定义一个public String 类型的变量 给予get set方法

在拼接结束后将字符串复制给你类中的变量 


在页面直接用${变量名} 即可