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


Java RequestContextUtils.getTimeZone方法代碼示例

本文整理匯總了Java中org.springframework.web.servlet.support.RequestContextUtils.getTimeZone方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestContextUtils.getTimeZone方法的具體用法?Java RequestContextUtils.getTimeZone怎麽用?Java RequestContextUtils.getTimeZone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.servlet.support.RequestContextUtils的用法示例。


在下文中一共展示了RequestContextUtils.getTimeZone方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTimeZone

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Override
public TimeZone getTimeZone() {
	TimeZone timeZone = RequestContextUtils.getTimeZone(this.request);
	return (timeZone != null ? timeZone : super.getTimeZone());
}
 
開發者ID:ghimisradu,項目名稱:spring-velocity-adapter,代碼行數:6,代碼來源:VelocityView.java

示例2: resolveZoneId

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
private ZoneId resolveZoneId(HttpServletRequest request) {
    TimeZone timeZone = RequestContextUtils.getTimeZone(request);
    return (timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault());
}
 
開發者ID:Exercon,項目名稱:AntiSocial-Platform,代碼行數:5,代碼來源:ArticleRestController.java

示例3: resolveArgument

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

	Class<?> paramType = parameter.getParameterType();
	if (WebRequest.class.isAssignableFrom(paramType)) {
		return webRequest;
	}

	HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
	if (ServletRequest.class.isAssignableFrom(paramType) || MultipartRequest.class.isAssignableFrom(paramType)) {
		Object nativeRequest = webRequest.getNativeRequest(paramType);
		if (nativeRequest == null) {
			throw new IllegalStateException(
					"Current request is not of type [" + paramType.getName() + "]: " + request);
		}
		return nativeRequest;
	}
	else if (HttpSession.class.isAssignableFrom(paramType)) {
		return request.getSession();
	}
	else if (HttpMethod.class == paramType) {
		return ((ServletWebRequest) webRequest).getHttpMethod();
	}
	else if (Principal.class.isAssignableFrom(paramType)) {
		return request.getUserPrincipal();
	}
	else if (Locale.class == paramType) {
		return RequestContextUtils.getLocale(request);
	}
	else if (TimeZone.class == paramType) {
		TimeZone timeZone = RequestContextUtils.getTimeZone(request);
		return (timeZone != null ? timeZone : TimeZone.getDefault());
	}
	else if ("java.time.ZoneId".equals(paramType.getName())) {
		return ZoneIdResolver.resolveZoneId(request);
	}
	else if (InputStream.class.isAssignableFrom(paramType)) {
		return request.getInputStream();
	}
	else if (Reader.class.isAssignableFrom(paramType)) {
		return request.getReader();
	}
	else {
		// should never happen...
		throw new UnsupportedOperationException(
				"Unknown parameter type: " + paramType + " in method: " + parameter.getMethod());
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:50,代碼來源:ServletRequestMethodArgumentResolver.java

示例4: resolveZoneId

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
public static Object resolveZoneId(HttpServletRequest request) {
	TimeZone timeZone = RequestContextUtils.getTimeZone(request);
	return (timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:ServletRequestMethodArgumentResolver.java

示例5: doSomething

import org.springframework.web.servlet.support.RequestContextUtils; //導入方法依賴的package包/類
@Override
@SuppressWarnings("deprecation")
public void doSomething(HttpServletRequest request) throws ServletException, IllegalAccessException {
	WebApplicationContext wac = RequestContextUtils.getWebApplicationContext(request);
	if (!(wac instanceof ComplexWebApplicationContext)) {
		throw new ServletException("Incorrect WebApplicationContext");
	}
	if (WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class) == null) {
		throw new ServletException("Not in a MultipartHttpServletRequest");
	}
	if (request.getParameter("fail") != null) {
		throw new ModelAndViewDefiningException(new ModelAndView("failed1"));
	}
	if (request.getParameter("access") != null) {
		throw new IllegalAccessException("illegal access");
	}
	if (request.getParameter("servlet") != null) {
		throw new ServletRequestBindingException("servlet");
	}
	if (request.getParameter("exception") != null) {
		throw new RuntimeException("servlet");
	}
	if (!(RequestContextUtils.getLocaleResolver(request) instanceof SessionLocaleResolver)) {
		throw new ServletException("Incorrect LocaleResolver");
	}
	if (!Locale.CANADA.equals(RequestContextUtils.getLocale(request))) {
		throw new ServletException("Incorrect Locale");
	}
	if (!Locale.CANADA.equals(LocaleContextHolder.getLocale())) {
		throw new ServletException("Incorrect Locale");
	}
	if (RequestContextUtils.getTimeZone(request) != null) {
		throw new ServletException("Incorrect TimeZone");
	}
	if (!TimeZone.getDefault().equals(LocaleContextHolder.getTimeZone())) {
		throw new ServletException("Incorrect TimeZone");
	}
	if (!(RequestContextUtils.getThemeResolver(request) instanceof SessionThemeResolver)) {
		throw new ServletException("Incorrect ThemeResolver");
	}
	if (!"theme".equals(RequestContextUtils.getThemeResolver(request).resolveThemeName(request))) {
		throw new ServletException("Incorrect theme name");
	}
	RequestContext rc = new RequestContext(request);
	rc.changeLocale(Locale.US, TimeZone.getTimeZone("GMT+1"));
	rc.changeTheme("theme2");
	if (!Locale.US.equals(RequestContextUtils.getLocale(request))) {
		throw new ServletException("Incorrect Locale");
	}
	if (!Locale.US.equals(LocaleContextHolder.getLocale())) {
		throw new ServletException("Incorrect Locale");
	}
	if (!TimeZone.getTimeZone("GMT+1").equals(RequestContextUtils.getTimeZone(request))) {
		throw new ServletException("Incorrect TimeZone");
	}
	if (!TimeZone.getTimeZone("GMT+1").equals(LocaleContextHolder.getTimeZone())) {
		throw new ServletException("Incorrect TimeZone");
	}
	if (!"theme2".equals(RequestContextUtils.getThemeResolver(request).resolveThemeName(request))) {
		throw new ServletException("Incorrect theme name");
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:63,代碼來源:ComplexWebApplicationContext.java


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