java 我怎样才能得到 PortletRequest

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16677377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 23:38:30  来源:igfitidea点击:

how can i get the PortletRequest

javaservletshttprequestportletspring-portlet-mvc

提问by EddyR

My problem is to obtain PortletRequestfrom HttpServletRequest

我的问题是PortletRequestHttpServletRequest

I put this sentence:

我把这句话:

PortletRequest request = (PortletRequest) HttpServletRequest.getAttribute();

What should I put into the .getAttribute();

我应该放入什么 .getAttribute();

When I developed in IBM Portlet Factory, I used .getAttribute(Constants.PORTLET_REQUEST)The Constants are into one .jar

当我在 IBM Portlet Factory 中开发时,我使用了.getAttribute(Constants.PORTLET_REQUEST)The Constants are into one.jar

Now I need to do this with Portletin JSR168or there is another way to obtain PortletRequestwithout using HttpServletRequest

现在,我需要做到这一点PortletJSR168或者有另一种方式来获得PortletRequest,而无需使用HttpServletRequest

I hope you can help me

我希望你能帮帮我

回答by Ramakrishna

You can use something like this:

你可以使用这样的东西:

(PortletRequest) request.getAttribute("javax.portlet.request");
(PortletResponse) request.getAttribute("javax.portlet.response");

Request and response are of HTTPServletRequestand HTTPSevletResponse.

请求和响应属于HTTPServletRequestHTTPSevletResponse

回答by Nick Roth

I assume you're programming a servlet since you have a HttpServletRequest and no PortletRequest. Which means you won't have a PortletRequest. You'll need to be programming portlets to get PortletRequests and in that case, the API interfaces and portlet container provide the PortletRequest.

我假设您正在编写一个 servlet,因为您有一个 HttpServletRequest 而没有 PortletRequest。这意味着您将没有 PortletRequest。您需要对 Portlet 进行编程以获取 PortletRequest,在这种情况下,API 接口和 Portlet 容器将提供 PortletRequest。

I don't know how the internals of Portlet Factory worked that you would need to obtain a PortletRequest like that but that's not typical portlet programming.

我不知道 Portlet Factory 的内部结构是如何工作的,您需要获得这样的 PortletRequest,但这不是典型的 Portlet 编程。

回答by npskirk

You say you are making a JSR 168 portlet.

你说你正在制作一个 JSR 168 portlet。

In that case your portlet class should be implementing javax.portlet.Portlet

在这种情况下,您的 portlet 类应该实现 javax.portlet.Portlet

To implement that interface you implement:

要实现该接口,请执行以下操作:

render(RenderRequest, RenderResponse)

render(RenderRequest, RenderResponse)

and

processAction(ActionRequest, ActionResponse)

processAction(ActionRequest, ActionResponse)

These are called by the portlet container when it decides to render your portlet or handle a user action from your portlet.

当 portlet 容器决定呈现您的 portlet 或处理来自您的 portlet 的用户操作时,它们会被调用。

The request objects RenderRequestand ActionRequestare PortletRequests. So you get it directly as an argument, you don't have to query something for it.

请求对象RenderRequestActionRequestPortletRequests。因此,您可以直接将其作为参数获取,而不必为它查询某些内容。