1

「/page1.jsp」、「/page2.jsp」、「file.java」の 2 つの JSP ページがあります。「/page1」からフォームを送信した後、アクション メソッドに移動して、データベースからいくつかのレコードを取得し、私が持っているレコードを含む「/ page2」とリストします。すべてが完了しましたが、何らかの理由で「/page2」ページに移動できず、別の場所 (別の .jsp ページ) に移動します。

liferay を使用し、MVCPortlet クラスを拡張しています

前もって感謝します!!!。

public void AddCustomer(ActionRequest actionRequest, ActionResponse actionResponse) throws                  IOException, PortletException {

    ...

    pCustomer.setCustomerId(customerId);

    // set UI fields
    pCustomer.setName(cusName);
    pCustomer.setAddress(address);
    pCustomer.setComments(comments);
    try {
        PCustomerLocalServiceUtil.addPCustomer(pCustomer);
    } catch (com.liferay.portal.kernel.exception.SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    ...
}

addCustomer.jsp:

<portlet:actionURL var="addCustomersAct" name="AddCustomer">
<portlet:param name="jspPage" value="/allCustomers.jsp"/>
</portlet:actionURL>  
<form method="post" action="<%= addCustomersAct %>">
 ...
</form>

allCustomers.jsp

<%for (PCustomer allCustomer : customers) { %>
<tr>
 ...//List of all customers
</tr>
<% } %>

addCustomers.jsp の上に、さらにいくつかのポートレット パラメータがあります。これは、サイドメニューがあり、レンダリング リクエストに必要であるためです。

4

4 に答える 4

2

addCustomer.jsp で renderURL を 1 つ作成し、これを隠しパラメータとしてリダイレクト URL として提供します。

...
    <portlet:renderURL var="redirectURL">
    <portlet:param name="jspPage" value="/html/yourhtmlpath/confirm.jsp"/>
    </portlet:renderURL>
...

<form>
    ...
        <aui:input name="redirectURL" type="hidden" value="${redirectURL}"></aui:input>
    ...
</form>

タスクを実行した後の processAction メソッドで:

...
    actionResponse.sendRedirect(ParamUtil.getString(actionRequest, "redirectURL"));
...
于 2013-06-20T15:01:59.673 に答える
1

catchブロックの後に、次のコード ステートメントを追加できます。

actionResponse.sendRedirect("page2.jsp");
于 2013-05-07T09:26:10.057 に答える
0
 In place of mul change the object according to your requirement whatever value you want which is redirected to jsp
        actionRequest.setAttribute("mul",mul);
        actionResponse.setRenderParameter("jspPage", "/jsp/b.jsp");
In jsp:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<h6>Mul</h6>
<%= renderRequest.getAttribute("mul") %>
于 2013-05-08T04:24:26.227 に答える