1

我想用 Search 的 portlet 获取搜索的关键字。我看到在 url 中出现:“struts_action=/search/seach”然后我在 strut-config.xml 中查找并找到:
action path="/search/search" forward="portlet.search.search"

我正在尝试做一个支柱,但我对支柱不太了解,而且它不起作用。这是“liferay-hook.xml”的代码:

<portal-properties>portal.properties</portal-properties>
<struts-action>
    <struts-action-path>/search/search</struts-action-path>
    <struts-action-impl>com.segmentationProject.searchAction.struts.SearchAction</struts-action-impl>
</struts-action>

portal.properties: auth.public.paths=/search/search

SearchAction.java:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.liferay.portal.kernel.struts.BaseStrutsAction;

public class SearchAction extends BaseStrutsPortletAction {  
    @Override
    public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
        System.out.println("inside the process ");
        super.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse);
    }

    @Override
    public String render(StrutsPortletAction originalStrutsPortletAction,PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
    // TODO Auto-generated method stub
        System.out.println("inside the render");
        return super.render(portletConfig, renderRequest, renderResponse);
    }
}

关于我错过或做错的任何想法?我只想获取关键字,然后正常进行搜索。谢谢!

4

2 回答 2

1

我认为这个可以完成这项工作:

String keywords = ParamUtil.getString(actionRequest, "keywords");

ParamUtil使用 portlet 名称空间来检索参数。

于 2013-10-07T15:29:43.137 回答
0

我认为您必须使用 originalStrutsPortletAction 而不是 super。

super.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse);
}

只需将 super 替换为 originalStrutsPortletAction

    originalStrutsPortletAction .processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse);
}
于 2017-05-15T12:38:16.350 回答