struts2.0中在页面上显示错误消息的问题!!!!

小弟刚接触到struts2.0,以前学的是1.x,是个新手,希望大家帮我解决一下问题,
是这样的,我要把action中,自己定义的异常显示到velocity页面上,请问要怎么作啊,我在action中用的是addActionError(getText("conditionForm.biz_id"));不知道这样可以不可以,我把代码发上来,望大家帮我解决一下,急,摆脱了,在先等候。
。。。。。。。。。。。
public String execute() throws Exception {
String bizId = getBiz_id();
if (ToolKit.isNullOrBlank(bizId)) {
//setMessage("业务类型不正确");(要在页面显示的内容)
addActionError(getText("conditionForm.biz_id"));
return ERROR;
}
UrpTemplate urpTemplate = null;
try {
urpTemplate = urpTemplateHelper.getTemplateById(bizId);
} catch (Exception e) {
//e.printStackTrace();
addActionError(getText("vmt.parse.error"));
return ERROR;
}
if (urpTemplate == null) {
//setMessage("未定义该业务类型的模板");(要在页面显示的内容)
addActionError(getText("biz_id.vmt.undifined"));
return ERROR;
}

reportGenerator.setUrpTemplate(urpTemplate);

try {
Map<String, Object> resultMap = reportGenerator.generate();
Iterator<String> it = resultMap.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
request.setAttribute(key, resultMap.get(key));
}
} catch (Exception e) {
//e.printStackTrace();
//setMessage("查询数据库出现异常");(要在页面显示的内容)
addActionError(getText("mar.gen.error"));
return ERROR;
}
return SUCCESS;
}

大家帮我看看我addActionError(getText("。。。。。。。。"));这样写对么?要是不对,我该怎么写?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值