当前位置: 首页>>代码示例>>Java>>正文


Java Config.get方法代码示例

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


在下文中一共展示了Config.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: tilesJstlView

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

	StaticWebApplicationContext wac = prepareWebApplicationContext();

	InternalResourceViewResolver irvr = new InternalResourceViewResolver();
	irvr.setApplicationContext(wac);
	irvr.setViewClass(TilesJstlView.class);
	View view = irvr.resolveViewName("testTile", new Locale("nl", ""));

	MockHttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
	MockHttpServletResponse response = new MockHttpServletResponse();
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
	wac.addMessage("code1", locale, "messageX");
	view.render(new HashMap<String, Object>(), request, response);

	assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
	ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
	assertNotNull(cc);
	PathAttribute attr = (PathAttribute) cc.getAttribute("content");
	assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());

	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:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:TilesViewTests.java

示例10: tilesJstlViewWithContextParam

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

	StaticWebApplicationContext wac = prepareWebApplicationContext();
	((MockServletContext) wac.getServletContext()).addInitParameter(
			Config.FMT_LOCALIZATION_CONTEXT, "org/springframework/web/servlet/view/tiles/context-messages");

	InternalResourceViewResolver irvr = new InternalResourceViewResolver();
	irvr.setApplicationContext(wac);
	irvr.setViewClass(TilesJstlView.class);
	View view = irvr.resolveViewName("testTile", new Locale("nl", ""));

	MockHttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
	MockHttpServletResponse response = new MockHttpServletResponse();
	wac.addMessage("code1", locale, "messageX");
	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
	request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));

	view.render(new HashMap<String, Object>(), request, response);
	assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
	ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
	assertNotNull(cc);
	PathAttribute attr = (PathAttribute) cc.getAttribute("content");
	assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());

	LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
	assertEquals("message1", lc.getResourceBundle().getString("code1"));
	assertEquals("message2", lc.getResourceBundle().getString("code2"));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:TilesViewTests.java

示例11: resolveLocale

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
@Override
public Locale resolveLocale(HttpServletRequest request) {

   Object locale = Config.get(request, Config.FMT_LOCALE);
   if (locale == null) {
      HttpSession session = request.getSession(false);
      if (session != null) {
         locale = Config.get(session, Config.FMT_LOCALE);
      }
   }

   return (locale instanceof Locale ? (Locale) locale : null);
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:14,代码来源:JstlLocaleResolver.java

示例12: resolveLocale

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
public Locale resolveLocale(final HttpServletRequest request) {

		return (Locale) Config.get(request.getSession(), Config.FMT_LOCALE);
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:JstlResolver.java


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