服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > 专题栏目 > STRUTS专题 > 查看文档

struts框架下,在jsp页面显示XSL格式化的XML

struts框架下,在jsp页面显示XSL格式化的XML。需要以下步骤:
1 页面显示前XML的Dom对象和Xsl文件地址存入request

package com.nova.colimas.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.w3c.dom.Element;
import org.w3c.dom.Document ;
import com.nova.colimas.common.xml.XMLObject;
import com.nova.colimas.web.constants.XslPathConstants;
import com.nova.colimas.web.constants.dtdPathConstants;
import com.nova.colimas.common.resources.dtd.ubiDtd;
import javax.servlet.jsp.PageContext;

public class LoadDataAction extends Action {
        private Document mydata;
        private String xslPath;

        public ActionForward execute(ActionMapping mapping,
                         ActionForm form,
                         HttpServletRequest request,
                         HttpServletResponse response)
        throws Exception{
                mydata=loadData();
                xslPath=”resources/example.xsl”;
                //XML的Dom对象
                request.setAttribute("userXml",mydata);
                        //Xsl文件地址
                request.setAttribute("bodyXsl",xslPath);
                return mapp

扫描关注微信公众号