从 portlet 中的 doView 方法重定向

发布于 2024-07-15 23:06:27 字数 139 浏览 6 评论 0原文

我正在使用 Websphere Portal 6.0,我想知道是否有一种方法可以告诉服务器从 doView 方法呈现哪个页面。 我知道我可以通过 processAction 方法来做到这一点,但不幸的是问题的语义不允许这样做。

感谢您的帮助

I'm using Websphere portal 6.0 and I'm wondering if there's a way in which I can tell the server which page to render from the doView method. I know I can do it from the processAction method but unfortunately the semantics of the problem don't allow it.

Thank you for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抚笙 2024-07-22 23:06:27

据我了解,您想要决定向用户显示哪个 JSP/HTML 页面。

在这种情况下,这就是您需要做的。

public void doView(RenderRequest req, RenderResponse res) throws IOException,
PortletException {

    PortletRequestDispatcher prd =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
    prd.include(req, res);
}

您可以决定每次要获取哪个jsp 的请求调度程序。

As I understand, you want to decide which JSP/HTML page you are going to show to the user.

In that case, this is what you need to do.

public void doView(RenderRequest req, RenderResponse res) throws IOException,
PortletException {

    PortletRequestDispatcher prd =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
    prd.include(req, res);
}

You can decide each time which jsp you want to obtain the request dispatcher for.

好菇凉咱不稀罕他 2024-07-22 23:06:27

我怀疑是否可以在 doView() 中发送重定向。 原因有两个:

  • 出于性能和各种其他原因,门户可能会在生成并发送门户的 HTTP 响应标头后调用 doView() - 因此为时已晚,无法发出重定向。
  • 能够做到这一点可能相当“邪恶”——门户可以随时调用 portlet 的 doView(),而无需用户与该 portlet 进行交互。 因此,Portlet 可以在随机页面刷新或与另一个 Portlet 交互后执行重定向。

一般来说,我想说如果 portlet 需要在 doView 中进行重定向,那么它可能需要重新设计。 也许尝试更详细地描述您的问题。

I doubt it is possible to send a redirect in doView(). Two reasons for that:

  • For performance and various other reasons, the portal may call doView() after the headers of portal's HTTP response were generated and sent out - thus too late to issue a redirect.
  • It could be pretty "evil" to be able to do that - a portlet's doView() can be called anytime by the portal, without user's interaction with that portlet. Thus a portlet could do the redirect after a random page refresh, or interaction with another portlet.

In general, I'd say if portlet needs to do a redirect in doView, then it may require a redesign. Perhaps try to describe your problem in more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文