一个Portlet内的多个页面

编程入门 行业动态 更新时间:2024-10-26 07:29:13
本文介绍了一个Portlet内的多个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我很好奇是否有人知道单个portlet是否可能包含多个页面,让我们说JSP页面。此外,是否可以链接到同一个portlet中的这些不同页面?

I am curious if anyone knows if it is possible for a single portlet to contain multiple pages, let's say JSP pages. Furthermore is it possible to link to these different pages within the same portlet?

例如。假设我有一个portlet。在这个portlet中,我希望初始视图是一个JSP页面,它只有5个链接到5个不同的JSP页面。当用户单击这5个链接中的一个时,它会将相应的JSP页面加载到portlet中。

For example. Let's say I have a single portlet. And in this portlet I want the initial view to be a JSP page with just 5 links on it to 5 different JSP pages. And when a user clicked on one of these 5 links, it would load the appropriate JSP page into the portlet.

最终目标基本上是一个包含在portlet中的小型迷你网站。

The end goal would basically be a little mini website all contained inside a portlet.

现在,我明白了这可能不是portlet的最佳用途,但是为了我正在开发的项目,我仍然想知道它是否可行。

Now, I understand that this might not be the best use of a portlet, but for the sake of a project I am working on, I still would like to know if it is possible.

谢谢!

推荐答案

当然,一个portlet可以包含多个JSP。

Sure, a portlet can contain more than one JSP.

您可以通过显示您想要的任何JSP您的 .RenderResponse)rel =nofollow noreferrer> doView (或 doHelp 或 doEdit )方法:

You can display any JSP you want via the PortletRequestDispatcher in your doView (or doHelp or doEdit) method:

protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, IOException, UnavailableException { resp.setContentType("text/html"); String myview = req.getParameter("myview"); String view = "/WEB-INF/jsp/" + (myview==null ? "bar" : myview) + ".jsp"; PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(view); dispatcher.include(req, resp); }

您可以使用参数来设置视图。在带有链接的JSP中,您需要使用Portlet API来创建/编码指向Portlet的链接。例如:

You could use a parameter to set the view. In the JSP with the links, you'd need to use the Portlet API to create/encode the links to the Portlet. For example:

<portlet:renderURL> <portlet:param name="myview" value="foo"/> </portlet:renderURL>

(我还没有及时了解JSR286 / Portlet 2.0 - 这些东西应该可行使用JSR168 / Portlet 1.0 - 如果您正在使用它,则值得检查新API。)

更多推荐

一个Portlet内的多个页面

本文发布于:2023-10-07 17:42:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470065.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   页面   Portlet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!