本文整理匯總了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";
}