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


Java RequestAttributes.setAttribute方法代码示例

本文整理汇总了Java中org.springframework.web.context.request.RequestAttributes.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java RequestAttributes.setAttribute方法的具体用法?Java RequestAttributes.setAttribute怎么用?Java RequestAttributes.setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.context.request.RequestAttributes的用法示例。


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

示例1: adjustViewName

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
public static String adjustViewName(String viewName) {
		
		RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();

		String jspPrefix = (String) requestAttributes.getAttribute("jspPrefix", RequestAttributes.SCOPE_REQUEST);
		if (jspPrefix == null || "".equals(jspPrefix)) jspPrefix = comDefaultPath;
		
		String jspPage = jspPrefix + viewName;	
		
//		LOG.debug("jspPage = " + jspPage);

		// if tiles exist, forward tiles layout
		String aTrgetId   = (String) requestAttributes.getAttribute("curTrgetId", RequestAttributes.SCOPE_REQUEST);
		String aCurMenuNo = (String) requestAttributes.getAttribute("curMenuNo", RequestAttributes.SCOPE_REQUEST);
		if( aTrgetId != null
				&& aTrgetId.startsWith("CMMNTY_") 
				&& aCurMenuNo != null
				&& !"".equals(aCurMenuNo) )  {
			
			requestAttributes.setAttribute("jspPage", jspPage, RequestAttributes.SCOPE_REQUEST);
			
			return "forward:/cop/cmy/CmmntyTilesPage.do";
		}
		
		return jspPage;
	}
 
开发者ID:aramsoft,项目名称:aramcomp,代码行数:27,代码来源:WebUtil.java

示例2: getErrorAttributes

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
@Override
public Map<String, Object> getErrorAttributes(
        RequestAttributes requestAttributes,
        boolean includeStackTrace) {

    Map<String, Object> errorAttributes = super.getErrorAttributes(requestAttributes, true);

    Throwable throwable = getError(requestAttributes);

    ErrorStatusCodeAndMessage errorStatusCodeAndMessage = exceptionStatusCodeAndMessageResolver
        .resolveStatusCodeAndMessage(
            throwable,
            (String) errorAttributes.get("message"),
            (Integer) requestAttributes.getAttribute("javax.servlet.error.status_code", 0));

    errorAttributes.put("error", errorStatusCodeAndMessage.getMessage());
    requestAttributes.setAttribute("javax.servlet.error.status_code", errorStatusCodeAndMessage.getStatusCode(), 0);
    errorAttributes.put("status", errorStatusCodeAndMessage.getStatusCode());


    log.error(
        errorStatusCodeAndMessage.getMessage(),
        StructuredArguments.keyValue("errorCode", errorStatusCodeAndMessage.getMessage()),
        StructuredArguments.keyValue("stackTrace", errorAttributes.get("trace"))
    );


    if (!globalIncludeStackTrace) {
        errorAttributes.remove("exception");
        errorAttributes.remove("trace");
    }
    errorAttributes.remove("message");

    return errorAttributes;
}
 
开发者ID:hmcts,项目名称:document-management-store-app,代码行数:36,代码来源:ApiErrorAttributes.java

示例3: setWxRequestToRequest

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
/**
 * 同上面方法,不过request从RequestContextHolder中取
 * @param wxRequest
 */
public static void setWxRequestToRequest(WxRequest wxRequest) {
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (requestAttributes != null) {
        requestAttributes.setAttribute(WX_REQUEST_ATTRIBUTE, wxRequest, RequestAttributes.SCOPE_REQUEST);
    }
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:11,代码来源:WxWebUtils.java

示例4: isValid

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
/**
 * 数据验证
 * 
 * @param target
 *            验证对象
 * @param groups
 *            验证组
 * @return 验证结果
 */
protected boolean isValid(Object target, Class<?>... groups) {
	Set<ConstraintViolation<Object>> constraintViolations = validator.validate(target, groups);
	if (constraintViolations.isEmpty()) {
		return true;
	} else {
		RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
		requestAttributes.setAttribute(CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME, constraintViolations, RequestAttributes.SCOPE_REQUEST);
		return false;
	}
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:20,代码来源:BaseController.java

示例5: addLog

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
/**
 * 添加日志
 * 
 * @param content
 *            内容
 */
protected void addLog(String content) {
	if (content != null) {
		RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
		requestAttributes.setAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME, content, RequestAttributes.SCOPE_REQUEST);
	}
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:13,代码来源:BaseController.java

示例6: cmmntyMainPageHandler

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
private String cmmntyMainPageHandler(
		String cmmntyId, 
		String menuId, 
		String contentUrl) {

	if( cmmntyId == null || cmmntyId.equals("") ) {
		throw new RuntimeException("cmmntyId not found");
	}
	
       CommunityVO communityVO = cmmntyService.getCommunityInfo(cmmntyId, menuId);

       // --------------------------------
	// 컨텐트 URL 정보
	// --------------------------------
	if( "".equals(menuId) && communityVO.getTopMenuList().size() != 0 ) {
		menuId = communityVO.getTopMenuList().get(0).get("menuNo").toString();
	}
	
	if( "".equals(contentUrl) ) {
		contentUrl = getMenuInfo(communityVO, menuId, "chkURL");
		if( "".equals(contentUrl) ) {
			contentUrl =  "/cop/cmy/CmmntyMainContents.do";
		}
	}
	
	RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
	requestAttributes.setAttribute("curTrgetId", communityVO.getCmmntyId(), RequestAttributes.SCOPE_REQUEST);
	requestAttributes.setAttribute("curMenuNo", menuId, RequestAttributes.SCOPE_REQUEST);

   	return "forward:"+contentUrl;
}
 
开发者ID:aramsoft,项目名称:aramcomp,代码行数:32,代码来源:CmyMenuHomeController.java

示例7: setAttribute

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
@Override
public void setAttribute(RequestAttributes request, String name, Object value) {
    request.setAttribute(name, value, RequestAttributes.SCOPE_SESSION);
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:5,代码来源:HttpSessionSessionStrategy.java

示例8: tagWithException

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
public static void tagWithException(Throwable exception) {
    RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
    attributes.setAttribute(EXCEPTION_ATTRIBUTE, exception,
        RequestAttributes.SCOPE_REQUEST);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:6,代码来源:MetricsFilter.java

示例9: setWxWebUserToSession

import org.springframework.web.context.request.RequestAttributes; //导入方法依赖的package包/类
public static void setWxWebUserToSession(WxWebUser wxWebUser) {
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (requestAttributes != null) {
        requestAttributes.setAttribute(WX_SESSION_USER, wxWebUser, RequestAttributes.SCOPE_SESSION);
    }
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:7,代码来源:WxWebUtils.java


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