struts.xml のアクション構成が次のようになっている場合は問題ありません。
<action name="customer-form">
<result name="success" type="tiles">/customer.tiles</result>
</action>
アクション構成 (struts.xml) でアクション クラスにアクセスすると問題が発生します。アクション クラスでインスタンス化するときに、フォームのドロップダウン オプションに適切な値を表示させるため、フォームを表示する前にクラスにアクセスします。しかし、それは「入力」を返すので、それを処理する必要があります。
アクション クラスのメソッド:
public String addCusto(){
custoType = new ArrayList<String>();
custoType.add("ABC");
custoType.add("EFG");
System.out.println(custoType.size());
return SUCCESS;
}
struts.xml:
<action name="customer-form" class="com.satunol.struts.template.action.CustomerAction" method="addCusto">
<result name="success" type="tiles">/customer.tiles</result>
<result name="input" type="tiles">/customer.tiles</result>
</action>
jspのフォーム
<s:form action="savecusto" method="post" validate="true">
<s:select
label="Customer Type"
list="custoType"
emptyOption="true"
headerKey="-1"
headerValue="None"/>
<s:textfield name="custo.name" key="custo.name" size="20" />
<s:textfield name="custo.email" key="email" size="20" />
<s:textfield name="custo.address" key="address" size="20" />
<s:textfield name="custo.phone" key="phone" size="20" />
<s:submit method="addCustomer" key="label.add.customer" align="center" />
結果?メソッドは実行されず、addCusto
フォームはまだ送信されていませんが、直接/自動的に検証されます。
どうすればこれを解決できますか?