2008-04-02
关于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
具体实现:
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
发表评论
- 浏览: 17565 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
我的相册
2008-6-26
共 122 张
共 122 张
最近加入圈子
最新评论
-
创建XMLHttpRequest对象及 ...
返回XML文档 PrintWriter out = null; try ...
-- by weiweichen1985 -
存储过程的创建和调用。。 ...
嵌套循环 CREATE DEFINER=`root`@`localhost` ...
-- by weiweichen1985 -
js实现的年月日三级联动
日历来的更简洁,让用户操作三遍,不符合用户体验。
-- by igogo007 -
js实现的年月日三级联动
谢谢了,代码我收藏了啊
-- by hanhan7673 -
word提示用安全模式打开
...
-- by sunfengcheng






评论排行榜