1

在 JSP 页面中,我有这个用于在 Liferay 中发出 AJAX 请求:

PortletURL portletURL = response.createRenderURL();
portleturl.setWindowState(LiferayWindowState.EXCLUSIVE);

我将把它portletURL作为 url 传递给下面的 JQuery 函数

jQuery.ajax({
    type: "POST",
    url: portleturl ,
    success: function(msg) {
        alert( "Data Saved: " + msg );
    }
});

这是我在文件中的动作映射struts.xml

<action name="helloForm" class="com.action.Struts2Action">
    <result name="input">/WEB-INF/view/index.jsp</result>
    <result name="success">/WEB-INF/view/result.jsp</result>
</action>

现在请告诉我如何将名为的动作设置helloFormportletURL

4

1 回答 1

0

It is common in the code of Liferay. For example, in this JSP file a link is created with a parameter defined by

<portlet:param name="struts_action" value="/asset_publisher/edit_subscription" />

(which points to this action mapping inside the huge Liferay struts-config.xml file).

So, I suppose you just need to add a parameter to your URL in the same way, with the sole difference of doing it with the PortletURL object:

PortletURL portletURL = response.createRenderURL();
portleturl.setWindowState(LiferayWindowState.EXCLUSIVE);
portletURL.setParameter("struts_action", "helloForm");
于 2013-03-27T14:45:37.113 回答