---
title: "利用html:error和html:message标签实现信息提示"
author: "fuyangchang"
date: "2007-06-10T15:32:00Z"
tags: []
slug: "html-error-html-message"
draft: false
lastmod: "2007-06-10T15:32:00Z"
id: 104083
url: "https://csdn.iteye.com/blog/104083"
---

利用html:error和html:message标签实现信息提示需要做三方面的处理:  
1.jsp页面中的代码片断:

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;table width="100%" align="left" border=0&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)      &lt;tr align="left"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)      &lt;td colspan="2" nowrap&gt;&lt;span class="ErrorStyle"&gt;&lt;html:errors/&gt;&lt;/span&gt;&lt;/td&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)      &lt;/tr&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/table&gt;

2.action中处理的方式:

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)String errMsg="数据库运行异常,请重新操作!";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)       Tools.set\_Error(errMsg,httpServletRequest);  
  Tools中的set\_Error代码部分  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)public static void set\_Error(String errMsg,HttpServletRequest httpServletRequest)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)     ActionErrors errors = new ActionErrors();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)     errors.add(ActionErrors.GLOBAL\_ERROR,new ActionError("cfy.public.error",errMsg));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)     httpServletRequest.setAttribute("org.apache.struts.action.ERROR", errors);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

3.在\\WebModule\\WEB-INF\\classes路径下新建文件ApplicationResources.properties,内容如下:  
cfy.public.error=错误:{0}  
cfy.public.message=提示:{0}  
4.在struts-config.xml文件中添加如下配置信息:  
  &lt;message-resources parameter="ApplicationResources\_zh\_CN" /&gt;