---
title: "html：errors 应用"
author: "yeer"
date: "2009-10-13T15:01:47Z"
tags: []
slug: "html-errors"
draft: false
lastmod: "2009-10-13T15:03:09Z"
id: 487003
url: "https://yeer.iteye.com/blog/487003"
---

1、创建属性文件，默认的英文属性文件名为ApplicationResources.properties，中文属性文件为ApplicationResources\_zh\_CH.properties

2、界面输出html：errors，方式为

显示所有的errors的书写方式：&lt;html:errors/&gt;

显示某一个errors的书写方式：&lt;html:errors property="username"/&gt;

3、可以再继承action的类中添加errors

ActionMessage messages=new ActionMessage("username");

ActionErrors errors=new ActionErrors();

errors.add("username", messages);

addErrors(request,errors);

如果这几步都完成，但是界面不正常显示，看jsp有没有引入标签库

&lt;%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %&gt;  
   &lt;%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %&gt;