user name is empty 解决方法!
我在actonform中的validate方法内这样定义:
ActionErrors errors=new ActionErrors();
if(name.trim().equals( " "))
{
ActionMessage error = new ActionMessage( "error.user_name ");
errors.add( "user_name ",error);
}
if(key.trim().equals( " "))
{
ActionMessage error = new ActionMessage( "error.user_key ");
errors.add( "user_key ",error);
}
在属性配置文件中:
error.user_name=user name is empty
error.user_key=user key is empty
在显示页中:
<html:errors property= "user_name "/>
<html:errors property= "user_key "/>
但是当用户名和密码输入框没有字符输入时,却没有'user name is empty
'这样的错误显示。
------解决方法--------------------------------------------------------
你要在struts-config.xml里配置你的属性文件
<message-resources parameter= "xxx.xxx.xxxResource_zh " />
------解决方法--------------------------------------------------------
ActionErrors errors=new ActionErrors();
if(name.trim().equals( " "))
{
ActionMessage error = new ActionMessage( "error.user_name ");
errors.add( "user_name ",error);
}
if(key.trim().equals( " "))
{
ActionMessage error = new ActionMessage( "error.user_key ");
errors.add( "user_key ",error);