为什么jsp:include参数不可见 [英] why jsp:include parameters not visible
问题描述
关于访问jsp:param值,我有一个完全相同的基本问题 a>作为此海报;遵循他的榜样对我完全不起作用.通过
I have exactly the same basic question about accessing jsp:param values as this poster; following his example exactly does not work for me. The parameters passed in via jsp:include don't seem to show up in the included file. Is there something peculiar about my setup?
来电者:
<div>
<jsp:include page="../../../common/callee.jsp">
<jsp:param name="justinVar" value="primary" />
</jsp:include>
</div>
callee.jsp:
callee.jsp:
<i>method 1: [</i><b><%= request.getParameter("justinVar") %></b><i>]</i>
<p/>
<i>method 2: [</i><b>${param.justinVar}</b><i>]</i>
<p/>
<i>method 3: [</i><b>${justinVar}</b><i>]</i>
<p/>
最终输出:
method 1: [null]
method 2: []
method 3: []
更新: 以下解决方法可以起作用,这似乎是错误的,但也许它起作用的事实揭示了一些不起作用的地方.
Update: The following workaround does work, it seems wrong, but perhaps the fact that it works reveals something that is not working.
<c:set var="justinVar" value="justinVARisHere" scope="request" />
<jsp:include page="../../../common/callee.jsp" />
推荐答案
要确定问题所在,请尝试通过在EL中打印${param}
或在Java代码中打印HttpServletRequest#getParameterMap()
来调试/探索整个地图.它必须提供有关真正地图包含的内容的见识.
To nail down the problem, try to debug/explore the entire map by printing ${param}
in EL or HttpServletRequest#getParameterMap()
in Java code. It must give insights about what the map really contains.
这篇关于为什么jsp:include参数不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!