我已經嘗試在Action類中添加操作錯誤並將它們打印到JSP頁面上。動作錯誤不會顯示在JSP上
發生異常時,它將進入catch塊並在控制檯中打印「插入異常,聯繫管理員時出錯」。
在catch塊,我已經與addActionError()
添加它,我已經試過在打印在jsp頁面...
但 jsp頁面不顯示的消息。
我可能會錯過或做錯了什麼?
Struts的映射:
<action name="dataUpdate" class="foo.bar.myAction" method="updation">
<result name="success" type="redirectAction">
../Aggregator/redirectToDataUpdate
</result>
</action>
Action類:
public String updation() throws JiffieTransactionException{
try {
// do stuff...
} catch (NumberFormatException e) {
addActionError("Error in inserting the Exception, Contact the Admin");
System.out.println("Error in inserting the Exception, Contact the Admin");
e.printStackTrace();
}
return SUCCESS;
}
進行打印動作的錯誤
JSP代碼:
<s:if test="hasActionErrors()">
<br></br>
<div class="errors">
<font color="red">
<s:actionerror/>
</font>
</div>
</s:if>
您能否詳細說明默認調度程序在我的代碼中的用法。 直到現在我還沒有使用它。 –
從你的結果聲明刪除redirectAction,並指向一個JSP: '<結果名稱=「成功」> result.jsp中' (如果沒有指定結果類型,'類型=「調度員」假定' ) –
但是,結果不應映射到jsp頁面,它應該映射到struts的另一個操作,它將填充數據並顯示生成的jsp頁面。 –