本文整理匯總了Java中org.springframework.context.support.ResourceBundleMessageSource.setParentMessageSource方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceBundleMessageSource.setParentMessageSource方法的具體用法?Java ResourceBundleMessageSource.setParentMessageSource怎麽用?Java ResourceBundleMessageSource.setParentMessageSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.ResourceBundleMessageSource
的用法示例。
在下文中一共展示了ResourceBundleMessageSource.setParentMessageSource方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getJstlAwareMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //導入方法依賴的package包/類
/**
* Checks JSTL's "javax.servlet.jsp.jstl.fmt.localizationContext"
* context-param and creates a corresponding child message source,
* with the provided Spring-defined MessageSource as parent.
* @param servletContext the ServletContext we're running in
* (to check JSTL-related context-params in {@code web.xml})
* @param messageSource the MessageSource to expose, typically
* the ApplicationContext of the current DispatcherServlet
* @return the MessageSource to expose to JSTL; first checking the
* JSTL-defined bundle, then the Spring-defined MessageSource
* @see org.springframework.context.ApplicationContext
*/
public static MessageSource getJstlAwareMessageSource(
ServletContext servletContext, MessageSource messageSource) {
if (servletContext != null) {
String jstlInitParam = servletContext.getInitParameter(Config.FMT_LOCALIZATION_CONTEXT);
if (jstlInitParam != null) {
// Create a ResourceBundleMessageSource for the specified resource bundle
// basename in the JSTL context-param in web.xml, wiring it with the given
// Spring-defined MessageSource as parent.
ResourceBundleMessageSource jstlBundleWrapper = new ResourceBundleMessageSource();
jstlBundleWrapper.setBasename(jstlInitParam);
jstlBundleWrapper.setParentMessageSource(messageSource);
return jstlBundleWrapper;
}
}
return messageSource;
}
示例2: createMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //導入方法依賴的package包/類
@Override
protected MessageSource createMessageSource(String basename) {
ResourceBundleMessageSource messageSource = (ResourceBundleMessageSource) super.createMessageSource(basename);
// Create parent theme recursively.
for (Theme theme : settingsService.getAvailableThemes()) {
if (basename.equals(basenamePrefix + theme.getId()) && theme.getParent() != null) {
String parent = basenamePrefix + theme.getParent();
messageSource.setParentMessageSource(createMessageSource(parent));
break;
}
}
return messageSource;
}
示例3: createMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //導入方法依賴的package包/類
@Override
protected MessageSource createMessageSource(String basename) {
ResourceBundleMessageSource messageSource = (ResourceBundleMessageSource) super.createMessageSource(basename);
ResourceBundleMessageSource parentMessageSource = new ResourceBundleMessageSource();
parentMessageSource.setBasename(defaultResourceBundle);
messageSource.setParentMessageSource(parentMessageSource);
return messageSource;
}