在Portlet环境中使用jsp:param/c:param [英] Using jsp:param / c:param in a Portlet Environment

查看:65
本文介绍了在Portlet环境中使用jsp:param/c:param的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆