问题描述
我试图在Portlet环境中将jsp:param
包含在JSP页面中(使用 Pluto portlet容器).
I'm trying to include JSP pages with jsp:param
in a Portlet environment (using the Pluto portlet container).
例如,
<jsp:include page="test.jsp">
<jsp:param name="foo" value="bar"/>
</jsp:include>
以及在test.jsp中,
and in test.jsp,
<c:out value="${foo}"/> or <%= request.getParameter("foo") %>
输出始终为null,我也尝试使用c
标记,但结果相同.
The output is always null and i've also tried using c
tags, but got the same result.
<c:import url="test.jsp">
<c:param name="foo" value="bar"/>
</c:import>
我已经在网上搜索了很多人,除了没有解决方案之外,他们都面临着同样的问题.
I've searched through the net and many people have faced the same problem, except that there is no solution to it.
这是一个限制吗?或者有其他方法可以做到吗?
Is this a limitation or is there a different way to do it?
推荐答案
在正常的Servlet环境中,此方法工作正常,但通过一些搜索,我发现Portlet环境似乎破坏了它.真可惜,但表明该portlet规范已被破坏.
This works fine in a normal Servlet environment, but I see from a bit of googling that the portlet environment seems to break it. This is a shame, but indicative that the portlet spec is, to put it bluntly, broken.
如果<jsp:param>
对您不起作用,则替代方法是使用请求属性:
If <jsp:param>
won't work for you, the alternative is to use request attributes instead:
<c:set var="foo" value="bar" scope="request"/>
<jsp:include page="test.jsp"/>
在test.jsp
中:
<c:out value="${requestScope.foo}"/>
或者也许只是
<c:out value="${foo}"/>
它不像使用params那样整洁和包含,但是它应该适用于portlet.
It's not as neat and contained as using params, but it should work for portlets.
这篇关于在Portlet环境中使用jsp:param/c:param的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!