关于ActionMessages的用法

当一个请求提交到服务器后,服务器进行处理,若输入错误或者进行提示,需要返回原输入页面将错误信息呈现给用户....

具体实现:

ApplicationResources.properties
====================================
# Resources for parameter 'com.lhcard.struts.ApplicationResources'
# Project LhCard


geren.userlogin.error.authencode=<font color="red">\u9a8c\u8bc1\u7801\u9519\u8bef</font>
geren.userlogin.error.password=<font color="red">\u5bc6\u7801\u9519\u8bef</font>
geren.userlogin.error.name=<font color="red">\u6ca1\u6709\u6b64\u7528\u6237</font>


geren.regisgter.error.name=<font color="red">\u6b64\u7528\u6237\u540d\u5df2\u88ab\u4eba\u6ce8\u518c\uff0c\u8bf7\u66f4\u6362\u4e00\u4e2a</font>


action:
=====================
ActionMessages messages = new ActionMessages();
messages.add("exist_name", new ActionMessage(
"geren.regisgter.error.name"));
request.setAttribute("msg", messages);
return mapping.findForward("reg");


jsp页面:
===========================
<html:messages id="c" name="msg" property="exist_name">
${c } </html:messages>

此标签中的name属性指定request作用域中的key,property指定错误消息的key
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值