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