struts多个properties,如何里面取值?
现在有pro1.properties,pro2.properties,两个配置文件。
在Struts-config.xml里面
<message-resources key="pro1" parameter="pro1" />
<message-resources key="pro2" parameter="pro2" />
ActionForm.java
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((username == null) || (username.length() < 1)){
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.username.required"));
}
if ((password == null) || (password.length() < 1))
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.password.required"));
return errors;
}
pro1.properties文件:
error.username.required = user
error.password.required = pass
运行时,报Cannot find message resources under key org.apache.struts.action.MESSAGE
我觉得原因是由于:errors返回时候没有指定相应的properties文件名。
请问该如何解决该问题,struts本身能解决不?