本文整理汇总了Java中org.springframework.context.support.ResourceBundleMessageSource.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundleMessageSource.getMessage方法的具体用法?Java ResourceBundleMessageSource.getMessage怎么用?Java ResourceBundleMessageSource.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.context.support.ResourceBundleMessageSource
的用法示例。
在下文中一共展示了ResourceBundleMessageSource.getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessage
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Override
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
String message = null;
for (ResourceBundleMessageSource source : sources) {
try {
message = source.getMessage(code, args, defaultMessage, locale);
break;
} catch (NoSuchMessageException e) {
//continue
}
}
if( message == null )
return super.getMessage(code, args, defaultMessage, locale);
return message;
}
示例2: ValidateUser
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
private String ValidateUser(User user){
ResourceBundleMessageSource r=new ResourceBundleMessageSource();
r.setBasename("messages_en");
user.setDob(new Date(user.getYear() - 1900, user.getMonth() - 1, user.getDay()));
if(user.getNick().length()==0)
return r.getMessage("judge.register.error.nick",null, new Locale("en"));
if ((user.getNick().length()) > 15)
return r.getMessage("judge.register.error.long25charact",null, new Locale("en"));
if (user.getNick().length() < 3)
return r.getMessage("judge.register.error.less3charact",null, new Locale("en"));
if (user.getName().length() < 1)
return r.getMessage("errormsg.7",null, new Locale("en"));
if (user.getName().length() > 30)
return r.getMessage("errormsg.6",null, new Locale("en"));
if (!user.getName().matches("[a-zA-Z\\.\\-\\'\\s]+"))
return r.getMessage("errormsg.8",null, new Locale("en"));
if (user.getLastname().length() < 1)
return r.getMessage("errormsg.10",null, new Locale("en"));
if (user.getLastname().length() > 50)
return r.getMessage("errormsg.9",null, new Locale("en"));
if (!user.getLastname().matches("[a-zA-Z\\.\\-\\'\\s]+"))
return r.getMessage("errormsg.11",null, new Locale("en"));
// si el correo ha sido cambiado y esta en uso por otra persona en el
// COJ
if(user.getEmail().length() == 0)
return r.getMessage("errormsg.51",null, new Locale("en"));
if (!StringUtils.isEmpty(user.getEmail()) && userDAO.bool("email.changed", user.getEmail(), user.getUid()) && userDAO.emailExistUpdate(user.getEmail().trim(), user.getUsername()))
return r.getMessage("judge.register.error.emailexist",null, new Locale("en"));
EmailValidator emailValidator = EmailValidator.getInstance(); //ver como inyectar este objeto
if (!emailValidator.isValid(user.getEmail()))
return r.getMessage("judge.register.error.bademail",null, new Locale("en"));
if (user.getCountry_id() == 0)
return r.getMessage("judge.register.error.country",null, new Locale("en"));
if (user.getInstitution_id() == 0)
return r.getMessage("judge.register.error.institution",null, new Locale("en"));
if (user.getLid() == 0)
return r.getMessage("judge.register.error.planguage",null, new Locale("en"));
if (user.getLocale() == 0)
return r.getMessage("judge.register.error.locale",null, new Locale("en"));
if(user.getName().length() == 0)
return r.getMessage("judge.register.error.name",null, new Locale("en"));
if (user.getGender() == 0)
return r.getMessage("judge.register.error.gender",null, new Locale("en"));
return "0";
}