English 中文(简体)
Struts2 行动之间的参数
原标题:Parameters between Struts2 Actions

在项目更新后,我需要留在同一页上,但我需要坦率地了解要取得哪些成功。 我举几个例子:

First one:

    <action
        name="add-item"
        method="addItem"
        class="com.deveto.struts.actions.ItemsAction" >
        <interceptor-ref name="defaultStack"/>
        <result name="success" type="redirectAction">
            <param name="actionName">show-update-item</param>
            <param name="itemId">${itemId}</param>
        </result>
    </action>

<>2>

    With an Action variable 以及setter & getter methods.

以及

    <action
        name="add-item"
        method="addItem"
        class="com.deveto.struts.actions.ItemsAction" >
        <interceptor-ref name="defaultStack"/>
        <result name="success" type="redirectAction">show-update-item</result>
    </action>

www.un.org/Depts/DGACM/index_spanish.htm 第三期:

    With request.setAttribute("itemId", itemId); 以及request.getAttribute("itemId");

以及

    <action
        name="add-item"
        method="addItem"
        class="com.deveto.struts.actions.ItemsAction" >
        <interceptor-ref name="defaultStack"/>
        <result name="success" type="redirectAction">show-update-item</result>
    </action>

Fourth one:

    With an Action variable 以及setter & getter methods.

以及the type="chain"

    <action
        name="add-item"
        method="addItem"
        class="com.deveto.struts.actions.ItemsAction" >
        <interceptor-ref name="defaultStack"/>
        <result name="success" type="chain">show-update-item</result>
    </action>

最后,《行动》是一个最新项目。

But all of this is giving me the same null result.

任何建议?

www.un.org/Depts/DGACM/index_french.htm Id=33(项目Id的参数)-> 编辑一些文本领域——和; 提交(请提交项目Id=33)-> 内容间接行动—> 内容更新项目.action(在我试图作废时)

最佳回答

如果我正确理解,你在选择第一个行动的项目后,在同一页重新停留,采取不同行动。 如果是这样的话,你的第一项行动定义应当发挥作用:

<action
    name="add-item"
    method="addItem"
    class="com.deveto.struts.actions.ItemsAction" >
    <interceptor-ref name="defaultStack"/>
    <result name="success" type="redirectAction">
        <param name="actionName">show-update-item</param>
        <param name="itemId">${itemId}</param>
    </result>
</action>

既然如此,你需要确保你在这两种行动(即行动1和行动2)中都有准入方法。

行动1 Id}正在通过信使和在行动2美元{项目 Id}应当通过固定方法确定。

Another option would be to consider using sessionaware. Simply set a session variable in action 1 and in action 2 retrieve the session variable and remove it from session if you re concerned about overhead. I tend to use session more often than not.

问题回答

与Russel建议一样,采取这一行动:

    <action
        name="add-item"
        method="addItem"
        class="com.deveto.struts.actions.ItemsAction" >
        <interceptor-ref name="defaultStack"/>
        <result name="success" type="redirectAction">
            <param name="actionName">show-update-item</param>
            <param name="itemId">${itemId}</param>
        </result>
    </action>

确保你们在项目行动方面有接触方法。 • 确保你利用它们来获得“项目Id”和“项目Attribute”的价值。

public String getItemId() {
    return itemId;
}

public void setItemId(String itemId) {
    this.itemId = itemId;
}

确切地说,当最后的转口实际发生时,你实际上在你的浏览器地址中看到“item更新项目:行动?itemId=33”。 如果问询中不通过“项目Id”,则绝对不能让你获得“项目Id”的价值。





相关问题
Convert typed-in Text to lowercase

I ve got an index.jsp with [snip] <% String name = request.getParameter("name"); String pass = request.getParameter("pass"); String globalname = "webeng"; String globalpass = "2009"; ...

session transfer issue from Tomcat to ASP.Net

I am using Tomcat to host JSP and using IIS 7.0 to host aspx (C# + .Net 3.5 + VSTS 2008), and I have some session transfer issue from JSP page to ASPX page. JSP page is in one domain and all other ...

Setting the default value in Struts2

I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the ...

Evaluate dynamically constructed JSP at runtime

I have a requirement where in the JSP page itself is created by the user and stored in the database. When viewing results we need to render this JSP to the client, evaluating all tags inside this JSP. ...

How to Pack/Encrypt/Unpack/Decrypt a bunch of files in Java?

I m essentially trying to do the following on a Java/JSP-driven web site: User supplies a password Password is used to build a strongly-encrypted archive file (zip, or anything else) containing a ...

JSP exception - class not found (tomcat)

I m setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). When I access it I get a series of stack traces with the following root ...

ArrayList to Table in JSP

I have an ArrayList and i am trying to display it in a table ..... ArrayList rows = .... ..... <table cellspacing="1" cellpadding="4" border="3"> <tr> <TH>...

热门标签