質問
以下のように私struts.xml ファイル
<action name="ProductVerification" class="com.frontend.ProductVerification">
<result name="success">/jsp/product_verification.jsp</result>
<result name="input">/jsp/product_verification.jsp</result>
<result name="error">/jsp/product_verification.jsp</result>
</action>
以下のような私のhtmlコード
<s:form name="frmVerification" id="frmVerification" onsubmit="Javascript: return checkFrmVerification(this);" >
<s:select name="countryId" id="cmbcountryid" headerKey="0" headerValue="%{getText('label.Please_Select')}" list="%{countryListCombo}" listKey="countryId" listValue="country" value="countryId" cssClass="style2" onchange="Javascript: GetCities();" required="true" />
<s:submit name="submit" src="images/submit_btn.jpg" type="image" value="submit" />
</form>
私の実行方法は以下のとおり。
public String execute() throws Exception {
Session session = this.getHibernateSession();
Transaction tx = session.beginTransaction();
//Following will set combo box containing country list
this.setCountryListCombo();
tx.commit();
return SUCCESS;
}
I amをオーバー検証方法は以下のとおり。
@Override
public void validate() {
HttpServletRequest request = this.getServletRequest();
if(request.getParameter(countryId) == 0){
addFieldError("countryId", "Please select country");
}
}
今の実行を自動で表示形式をcountryIdコンボボックスに満ちた国です。
今を提出しない形選択コンボボックスで表示エラーになります。
ものではなくエラ"を選択してください国"ちょっと以下のエラーになります。
Strutsの問題を報告
Strutsが検出されました独自のレンダリングメカニズムの例外:
メッセージ: タグ'を選択し、分野が'list',名countryId':要求されたリストキーが'%{countryListCombo}'が解決されるとして収集/配列/地図/列挙型/反復子タイプです。例:人は人です。{name}
ファイル: org/apache/jasper/servlet/JspServletWrapper.java
行番号: 522
きずいのはなぜそうなんだ。
この後のvalidate()メソッドを結="入力"ではない呼び出しexecute()メソッドではなくように"/jsp/product_verification.jsp"のページです。
力を貸してください解決の問題です。
感謝。
解決
おと仮定が正しい場合の分野のエラーが追加され、デフォルトを返しの"入力"の結果が入力の結果である描画されます。私はあなたが今の実施preparableれるよう、まず移植のコンボボックス前のページをレンダリング
他のヒント
必要なものを追加するためにはコンボボックスコード方式で以下のように:
public String execute() throws Exception {
//add this code also as per your comobobx code
countryList = new ArrayList<Country>();
countryList.add(new Country(1, "India"));
countryList.add(new Country(1, "Shri Lanka"));
countryList.add(new Country(1, "USA"));
countryList.add(new Country(1, "Pakistan"));
countryList.add(new Country(1, "NewsLnad"));
//add this code also as per your comobobx code
Session session = this.getHibernateSession();
Transaction tx = session.beginTransaction();
//Following will set combo box containing country list
this.setCountryListCombo();
tx.commit();
return SUCCESS;
}
ともに以下のエントリを追加すタグjspのページ
<s:actionerror />
所属していません StackOverflow