2

私は(ここにある)CustomerAction.javaの下にある という名前のStruts 2アクションを持っています。このアクション クラス内のメソッドの 1 つから、レガシー アクション クラスにリダイレクトしていますfolderHierarchy/actions/customercustomernamespace

Resultマッピングは次のとおりです。

@Result(name = "redirectTo", location = "#parameters.redirectLocation", type = "redirect") })

の値#parameters.redirectLocation

/customerhome.do?custIdId=200

Action方法は:

 @Action(value = "CustomerAction!redirectToPage")
  public String redirectToLocation() {
    return "redirectTo";
  }

customerしかし問題は、リダイレクトの場所の前に現在のアクション名前空間 (つまり ) を自動的に追加するストラットです。

したがって、リダイレクトする代わりに

/myWebApp/customerhome.do?custIdId=200

Struts 2はにリダイレクトしています

/myWebApp/customer/customerhome.do?custIdId=200

名前空間を追加する理由とcustomer、これを取り除く方法がわかりませんか?

私も試しました:

@Result(name = "redirectTo", location = "#parameters.redirectTo", type = "redirect", params = { "namespace", "/" }) })

しかし、それもうまくいきませんでした。

別の観察結果は次のとおりです。

何が機能するか:

@Result(name = ComposeMessageCrudAction.REDIRECT_TO, location = "/customerhome.do?custIdId=200", type = "redirect") })

何が機能しないか:

@Result(name = "redirectTo", location = "#parameters.redirectLocation", type = "redirect") })

の値#parameters.redirectLocation

/customerhome.do?custIdId=200

2番目のアプローチが機能しない理由と、customer前に名前空間を追加する理由がわかりません

/customerhome.do?custIdId=200

4

1 に答える 1

0

locationstruts 結果への動的パラメーターとして attributeの値を使用します。

private String redirectLocation = "/customerhome.do?custIdId=200";

public String getRedirectLocation() {
  return redirectLocation;
}

@Result(name = REDIRECT_TO, location = "${redirectLocation}", type = "redirect") 
于 2013-09-11T20:11:52.657 に答える