我已经尝试在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页面。 –