【发布时间】:2014-06-23 16:46:29
【问题描述】:
我正在尝试在从 servlet 传递的 JSP 中使用 xml 字符串。变量通过正常。我使用代码:
request.setAttribute("xml",xmlDoc_str2);
request.getRequestDispatcher("./jsp/pdirdetail.jsp").forward(request, response);
但是,我不确定如何在 jsp 端使用它。我需要解析它并在 JSP 中读取它。我正在使用代码:
<%=request.getAttribute("xml") %>
<%
try{
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(${xml}));
}
catch(Exception e){}
%>
它显然不喜欢我引用变量的方式。我不确定是否有其他方法可以做到这一点,或者我是否遗漏了什么。
【问题讨论】: