[英]Passing parameters between jsp and xsl
I have a problem between my jsp page and xsl, i want pass a parameter between the jsp and the xsl but it is never set in the xsl. 我在jsp页面和xsl之间有问题,我想在jsp和xsl之间传递参数,但从未在xsl中设置参数。
JSP page ; JSP页面;
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<%!
private String getVal(String param, HttpServletRequest request) {
return request.getParameter("fname");
}
%>
<%
String num = getVal("value", request);
%>
<div id="section" class="col-xs-10 col-sm-10 col-md-8">
<c:import url="/monXml.xml" var="inputDoc" />
<c:import url="/viewAnnonce.xsl" var="stylesheet" />
<x:transform xml="${inputDoc}" xslt="${stylesheet}" >
<x:param name="numAnnonce" value="${num}"/>
</x:transform>
</div>
XSL : XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
<xsl:param name="numAnnonce"/>
<xsl:template match="/">
<xsl:template match="/">
<!-- Creation de la liste des annonces -->
<xsl:for-each select=".//annonce[attribute::id=$numAnnonce]">
<div id="article" class="row"></div>
</xsl:for-each>
</xsl:template>
` `
The getVal("value", request); getVal(“ value”,request); return a correct value.
返回正确的值。
Thanks. 谢谢。
您已经使用JSP scriptlet声明了num
变量,我认为您不能使用${num}
来访问它,您是否可以尝试使用scriptlet来访问它:
<x:param name="numAnnonce" value="<%=num%>"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.