當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceBundleMessageSource.setParentMessageSource方法代碼示例

本文整理匯總了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;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:30,代碼來源:JstlUtils.java

示例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;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:15,代碼來源:CustomThemeSource.java

示例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;
}
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:11,代碼來源:SubsonicThemeSource.java


注:本文中的org.springframework.context.support.ResourceBundleMessageSource.setParentMessageSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。