• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.servlet.jsp.jstl.core.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Config类属于javax.servlet.jsp.jstl.core包,在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sessionCreated

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
/** HttpSessionListener interface */
   @Override
   public void sessionCreated(HttpSessionEvent sessionEvent) {
if (sessionEvent == null) {
    return;
}
HttpSession session = sessionEvent.getSession();
session.setMaxInactiveInterval(SessionListener.timeout);

//set server default locale for STURTS and JSTL. This value should be overwrite
//LocaleFilter class. But this part code can cope with login.jsp Locale.
if (session != null) {
    String defaults[] = LanguageUtil.getDefaultLangCountry();
    Locale preferredLocale = new Locale(defaults[0] == null ? "" : defaults[0],
	    defaults[1] == null ? "" : defaults[1]);
    session.setAttribute(LocaleFilter.PREFERRED_LOCALE_KEY, preferredLocale);
    Config.set(session, Config.FMT_LOCALE, preferredLocale);
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:SessionListener.java


示例2: getJstlAwareMessageSource

import javax.servlet.jsp.jstl.core.Config; //导入依赖的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


示例3: setupTextProvider

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
public static void setupTextProvider(ServletContext servletContext, ServletRequest request) {
    Locale locale = request.getLocale();
    ResourceBundleManager resourceBundleManager =
            (ResourceBundleManager) servletContext.getAttribute(BaseModule.RESOURCE_BUNDLE_MANAGER);
    ResourceBundle portofinoResourceBundle = resourceBundleManager.getBundle(locale);

    LocalizationContext localizationContext =
            new LocalizationContext(portofinoResourceBundle, locale);
    request.setAttribute(Config.FMT_LOCALIZATION_CONTEXT + ".request", localizationContext);

    //Setup Elements I18n
    ResourceBundle elementsResourceBundle =
            ResourceBundle.getBundle(SimpleTextProvider.DEFAULT_MESSAGE_RESOURCE, locale);

    TextProvider textProvider =
            new MultipleTextProvider(
                    portofinoResourceBundle, elementsResourceBundle);
    ElementsThreadLocals.setTextProvider(textProvider);
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:20,代码来源:I18nUtils.java


示例4: doFilter

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Override
public void doFilter(
        ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {
    //I18n
    Locale locale = request.getLocale();
    ResourceBundleManager resourceBundleManager =
            (ResourceBundleManager) servletContext.getAttribute(BaseModule.RESOURCE_BUNDLE_MANAGER);
    ResourceBundle portofinoResourceBundle = resourceBundleManager.getBundle(locale);

    LocalizationContext localizationContext =
            new LocalizationContext(portofinoResourceBundle, locale);
    request.setAttribute(Config.FMT_LOCALIZATION_CONTEXT + ".request", localizationContext);

    //Setup Elements I18n
    ResourceBundle elementsResourceBundle =
            ResourceBundle.getBundle(SimpleTextProvider.DEFAULT_MESSAGE_RESOURCE, locale);

    TextProvider textProvider =
            new MultipleTextProvider(
                    portofinoResourceBundle, elementsResourceBundle);
    ElementsThreadLocals.setTextProvider(textProvider);
    filterChain.doFilter(request, response);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:25,代码来源:I18nFilter.java


示例5: setTimeZone

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
private void setTimeZone(Context ctx, User user, HttpServletRequest request) {
    RhnTimeZone tz = null;
    if (user != null) {
        tz = user.getTimeZone();
        LOG.debug("Set timezone from the user.");
    }
    if (tz == null) {
        // Use the Appserver timezone if the User doesn't have one.
        String olsonName = TimeZone.getDefault().getID();
        if (LOG.isDebugEnabled()) {
            LOG.debug("olson name [" + olsonName + "]");
        }
        tz = UserManager.getTimeZone(olsonName);
        // if we're still null set it to a default
        if (tz == null) {
            tz = new RhnTimeZone();
            tz.setOlsonName(olsonName);

            LOG.debug("timezone still null");
        }
    }
    ctx.setTimezone(tz.getTimeZone());
    // Set the timezone on the request so that fmt:formatDate
    // can find it
    Config.set(request, Config.FMT_TIME_ZONE, tz.getTimeZone());
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:27,代码来源:LocalizedEnvironmentFilter.java


示例6: setOtherResourceBundles

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
/**
    * Sets the Stripes error and field resource bundles in the request, if their names have been configured.
    */
@Override
protected void setOtherResourceBundles(HttpServletRequest request)
{
	Locale locale = request.getLocale();

       if (errorBundleName != null)
       {
           ResourceBundle errorBundle = getLocalizationBundleFactory().getErrorMessageBundle(locale);
           Config.set(request, errorBundleName, new LocalizationContext(errorBundle, locale));
           LOGGER.debug("Loaded Stripes error message bundle ", errorBundle, " as ", errorBundleName);
       }

       if (fieldBundleName != null)
       {
           ResourceBundle fieldBundle = getLocalizationBundleFactory().getFormFieldBundle(locale);
           Config.set(request, fieldBundleName, new LocalizationContext(fieldBundle, locale));
           LOGGER.debug("Loaded Stripes field name bundle ", fieldBundle, " as ", fieldBundleName);
       }
}
 
开发者ID:StripesFramework,项目名称:stripes-stuff,代码行数:23,代码来源:JstlBundleInterceptor.java


示例7: findByKey

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
/**
 * Looks up a configuration variable in the request, session and application scopes. If none is found, return by
 * {@link ServletContext#getInitParameter(String)} method.
 */
private Object findByKey(String key) {
	Object value = Config.get(request, key);
	if (value != null) {
		return value;
	}

	value = Config.get(request.getSession(createNewSession()), key);
	if (value != null) {
		return value;
	}

	value = Config.get(request.getServletContext(), key);
	if (value != null) {
		return value;
	}

	return request.getServletContext().getInitParameter(key);
}
 
开发者ID:caelum,项目名称:vraptor4,代码行数:23,代码来源:JstlLocalization.java


示例8: doEndTag

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
public int doEndTag() throws JspException {
    try {
        init();
        
        ValueMap valueMap = request.getResource().adaptTo(ValueMap.class);
        I18nResourceBundle bundle = new I18nResourceBundle(valueMap,
                getResourceBundle(getBaseName(), request));
        
        // make this resource bundle & i18n available as ValueMap for TEI
        pageContext.setAttribute(getMessagesName(),
                bundle.adaptTo(ValueMap.class), 
                PageContext.PAGE_SCOPE);
        pageContext.setAttribute(getI18nName(), 
                new I18n(bundle), 
                PageContext.PAGE_SCOPE);

        // make this resource bundle available for fmt functions
        Config.set(pageContext, "javax.servlet.jsp.jstl.fmt.localizationContext", new LocalizationContext(bundle, getLocale(request)), 1);
    } catch(Exception e) {
        LOG.error(e.getMessage());
        throw new JspException(e);
    }
    return EVAL_PAGE;
}
 
开发者ID:steeleforge,项目名称:ironsites,代码行数:25,代码来源:I18nHelperTag.java


示例9: exposeLocalizationContext

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
/**
 * Exposes JSTL-specific request attributes specifying locale
 * and resource bundle for JSTL's formatting and message tags,
 * using Spring's locale and MessageSource.
 * @param request the current HTTP request
 * @param messageSource the MessageSource to expose,
 * typically the current ApplicationContext (may be {@code null})
 * @see #exposeLocalizationContext(RequestContext)
 */
public static void exposeLocalizationContext(HttpServletRequest request, MessageSource messageSource) {
	Locale jstlLocale = RequestContextUtils.getLocale(request);
	Config.set(request, Config.FMT_LOCALE, jstlLocale);
	TimeZone timeZone = RequestContextUtils.getTimeZone(request);
	if (timeZone != null) {
		Config.set(request, Config.FMT_TIME_ZONE, timeZone);
	}
	if (messageSource != null) {
		LocalizationContext jstlContext = new SpringLocalizationContext(messageSource, request);
		Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, jstlContext);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JstlUtils.java


示例10: getResourceBundle

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Override
public ResourceBundle getResourceBundle() {
	HttpSession session = this.request.getSession(false);
	if (session != null) {
		Object lcObject = Config.get(session, Config.FMT_LOCALIZATION_CONTEXT);
		if (lcObject instanceof LocalizationContext) {
			ResourceBundle lcBundle = ((LocalizationContext) lcObject).getResourceBundle();
			return new MessageSourceResourceBundle(this.messageSource, getLocale(), lcBundle);
		}
	}
	return new MessageSourceResourceBundle(this.messageSource, getLocale());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:JstlUtils.java


示例11: getLocale

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Override
public Locale getLocale() {
	HttpSession session = this.request.getSession(false);
	if (session != null) {
		Object localeObject = Config.get(session, Config.FMT_LOCALE);
		if (localeObject instanceof Locale) {
			return (Locale) localeObject;
		}
	}
	return RequestContextUtils.getLocale(this.request);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JstlUtils.java


示例12: getJstlLocale

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
public static Locale getJstlLocale(HttpServletRequest request, ServletContext servletContext) {
	Object localeObject = Config.get(request, Config.FMT_LOCALE);
	if (localeObject == null) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			localeObject = Config.get(session, Config.FMT_LOCALE);
		}
		if (localeObject == null && servletContext != null) {
			localeObject = Config.get(servletContext, Config.FMT_LOCALE);
		}
	}
	return (localeObject instanceof Locale ? (Locale) localeObject : null);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:RequestContext.java


示例13: getJstlTimeZone

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
public static TimeZone getJstlTimeZone(HttpServletRequest request, ServletContext servletContext) {
	Object timeZoneObject = Config.get(request, Config.FMT_TIME_ZONE);
	if (timeZoneObject == null) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			timeZoneObject = Config.get(session, Config.FMT_TIME_ZONE);
		}
		if (timeZoneObject == null && servletContext != null) {
			timeZoneObject = Config.get(servletContext, Config.FMT_TIME_ZONE);
		}
	}
	return (timeZoneObject instanceof TimeZone ? (TimeZone) timeZoneObject : null);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:RequestContext.java


示例14: testInternalResourceViewResolverWithJstl

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Test
public void testInternalResourceViewResolverWithJstl() throws Exception {
	Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;

	MockServletContext sc = new MockServletContext();
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.setServletContext(sc);
	wac.addMessage("code1", locale, "messageX");
	wac.refresh();
	InternalResourceViewResolver vr = new InternalResourceViewResolver();
	vr.setViewClass(JstlView.class);
	vr.setApplicationContext(wac);

	View view = vr.resolveViewName("example1", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example1", ((JstlView) view).getUrl());

	view = vr.resolveViewName("example2", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example2", ((JstlView) view).getUrl());

	MockHttpServletRequest request = new MockHttpServletRequest(sc);
	HttpServletResponse response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
	Map model = new HashMap();
	TestBean tb = new TestBean();
	model.put("tb", tb);
	view.render(model, request, response);

	assertTrue("Correct tb attribute", tb.equals(request.getAttribute("tb")));
	assertTrue("Correct rc attribute", request.getAttribute("rc") == null);

	assertEquals(locale, Config.get(request, Config.FMT_LOCALE));
	LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
	assertEquals("messageX", lc.getResourceBundle().getString("code1"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:ViewResolverTests.java


示例15: testInternalResourceViewResolverWithJstlAndContextParam

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Test
public void testInternalResourceViewResolverWithJstlAndContextParam() throws Exception {
	Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;

	MockServletContext sc = new MockServletContext();
	sc.addInitParameter(Config.FMT_LOCALIZATION_CONTEXT, "org/springframework/web/context/WEB-INF/context-messages");
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.setServletContext(sc);
	wac.addMessage("code1", locale, "messageX");
	wac.refresh();
	InternalResourceViewResolver vr = new InternalResourceViewResolver();
	vr.setViewClass(JstlView.class);
	vr.setApplicationContext(wac);

	View view = vr.resolveViewName("example1", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example1", ((JstlView) view).getUrl());

	view = vr.resolveViewName("example2", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "example2", ((JstlView) view).getUrl());

	MockHttpServletRequest request = new MockHttpServletRequest(sc);
	HttpServletResponse response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
	Map model = new HashMap();
	TestBean tb = new TestBean();
	model.put("tb", tb);
	view.render(model, request, response);

	assertTrue("Correct tb attribute", tb.equals(request.getAttribute("tb")));
	assertTrue("Correct rc attribute", request.getAttribute("rc") == null);

	assertEquals(locale, Config.get(request, Config.FMT_LOCALE));
	LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
	assertEquals("message1", lc.getResourceBundle().getString("code1"));
	assertEquals("message2", lc.getResourceBundle().getString("code2"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:ViewResolverTests.java


示例16: setLocale

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
/**
 * Setta a session scope la locale passata con chiave di attributo coerente a JSTL
 * @param pLocale
 * @param pHttpSession
 */
public static void setLocale(Locale pLocale, HttpSession pHttpSession) {
	if (pHttpSession==null || pLocale==null) throw new JBrickException(JBrickException.FATAL);
	mLog.debug("ENTER setLocale(Session) con locale ",pLocale.toString());
	Config.set(pHttpSession, Config.FMT_LOCALE, pLocale);
	mLog.debug("FINISH setLocale(Session)");
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:12,代码来源:LocaleUtil.java


示例17: getLocale

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
/**
 * Ritorna la Locale attualmente valida per quella sessione.
 * Viene ipotizzata la solita coerenza con JSTL.
 * Ritorna null nel caso la sessione non abbia una locale settata. 
 * 
 * @param httpSession
 */
public static Locale getLocale(HttpSession pHttpSession) {
	if (pHttpSession==null) throw new JBrickException(JBrickException.FATAL);
	mLog.debug("ENTER getLocale(Session)");
	Locale lLocale = (Locale) Config.get(pHttpSession, Config.FMT_LOCALE);
	if (lLocale != null) 
		mLog.debug("EXIT getLocale(Session) returning ",lLocale.toString());
	else mLog.debug("EXIT getLocale(Session) returning null");
	return lLocale;
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:17,代码来源:LocaleUtil.java


示例18: renderMergedOutputModel

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Override
protected void renderMergedOutputModel(Map<String, Object> model,HttpServletRequest request,HttpServletResponse response)
                throws Exception{

    String filterString = (String) model.get(JSON_FILTER_STR);
    model.remove(JSON_FILTER_STR);

    // 这个key 有问题
    // see com.jumbo.brandstore.web.view.CommonTilesView.renderMergedOutputModel(Map<String, Object>, HttpServletRequest,
    // HttpServletResponse)
    model.remove(Config.FMT_LOCALIZATION_CONTEXT + ".request");

    String writeStr = "";
    if (prefixJson){
        writeStr = "{} && ";
        response.getWriter().write(writeStr);

        if (LOGGER.isDebugEnabled()){
            LOGGER.debug(writeStr);
        }
    }
    if (model.size() > 0){
        if (filterString == null){
            filterString = "**";
        }

        //TODO
        // writeStr = JsonUtil.format(model, filterString);
        writeStr = JsonUtil.format(model);
    }else{
        //writeStr = new JSONObject().toString(4);
        writeStr = "{}";
    }

    response.getWriter().write(writeStr);

    if (LOGGER.isDebugEnabled()){
        LOGGER.debug("{} \t filterString:[{}] \n{}", RequestUtil.getRequestFullURL(request, UTF8), filterString, writeStr);
    }
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:41,代码来源:JsonView.java


示例19: testJstlLocaleIsSet

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
public void testJstlLocaleIsSet() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("locale", "es");

    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setSession(new MockHttpSession(null));
    
    filter.doFilter(request, response, new MockFilterChain());
    
    assertNotNull(Config.get(request.getSession(), Config.FMT_LOCALE));
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:12,代码来源:LocaleFilterTest.java


示例20: getBundle

import javax.servlet.jsp.jstl.core.Config; //导入依赖的package包/类
@Override @Produces
public ResourceBundle getBundle(Locale locale) {
	Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, null);
	ResourceBundle customBundle = super.getBundle(locale);
	Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, "mamute-messages");
	ResourceBundle mamuteBundle = super.getBundle(locale);
	
	return new MamuteResourceBundle(customBundle, mamuteBundle);
}
 
开发者ID:caelum,项目名称:mamute,代码行数:10,代码来源:MamuteLocalization.java



注:本文中的javax.servlet.jsp.jstl.core.Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExceptionEvent类代码示例发布时间:2022-05-21
下一篇:
Java IPresentationDamager类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap