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


Java MappingJackson2JsonView.setExtractValueFromSingleKeyModel方法代碼示例

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


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

示例1: handle4AsyncRequest

import org.springframework.web.servlet.view.json.MappingJackson2JsonView; //導入方法依賴的package包/類
protected ModelAndView handle4AsyncRequest(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
	ExceptionMetadata em = ModuleExceptionResolver.resolveException(ex);
	
	Result<Object> result = new Result<Object>();
	result.setSuccess(false);
	result.setCode(em.getCode());
	result.setMessage(em.getMessage());
	MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
	jsonView.setExtractValueFromSingleKeyModel(true);
	ModelAndView mav = new ModelAndView(jsonView);
	mav.addObject(result);
	return mav;
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:14,代碼來源:DefaultMvcHandlerExceptionResolver.java

示例2: generateModelAndViewForErrorResponse

import org.springframework.web.servlet.view.json.MappingJackson2JsonView; //導入方法依賴的package包/類
/**
 * Reusable static method for generating a ModelAndView that will be serialized to a JSON representation of the
 * DefaultErrorContractDTO.
 *
 * @return A ModelAndView that will be serialized to a JSON representation of the DefaultErrorContractDTO. (NOTE:
 * make sure the DefaultErrorContractDTO is FULLY populated before calling this method! Changes to the
 * DefaultErrorContractDTO after calling this method may not be reflected in the returned ModelAndView).
 */
public ModelAndView generateModelAndViewForErrorResponse(
    DefaultErrorContractDTO errorContractDTO, int httpStatusCode, Collection<ApiError> rawFilteredApiErrors,
    Throwable originalException, RequestInfoForLogging request
) {
    MappingJackson2JsonView view = new MappingJackson2JsonView();
    view.setExtractValueFromSingleKeyModel(true);
    view.setObjectMapper(getObjectMapperForJsonErrorResponseSerialization(
        errorContractDTO, httpStatusCode, rawFilteredApiErrors, originalException, request
    ));
    ModelAndView mv = new ModelAndView(view);
    mv.addObject(errorContractDTO);
    return mv;
}
 
開發者ID:Nike-Inc,項目名稱:backstopper,代碼行數:22,代碼來源:SpringApiExceptionHandlerUtils.java

示例3: resolveViewName

import org.springframework.web.servlet.view.json.MappingJackson2JsonView; //導入方法依賴的package包/類
@Override
public View resolveViewName(String viewName, Locale locale) throws Exception {
  MappingJackson2JsonView view = new MappingJackson2JsonView();
  view.setExtractValueFromSingleKeyModel(true);
  view.setPrettyPrint(true);
  return view;
}
 
開發者ID:puncha,項目名稱:petclinic,代碼行數:8,代碼來源:JsonViewResolver.java

示例4: asModelAndView

import org.springframework.web.servlet.view.json.MappingJackson2JsonView; //導入方法依賴的package包/類
/**
 * 根據SystemException返回視圖
 *
 * @param e SystemException
 * @return 視圖
 */
public static ModelAndView asModelAndView(SystemException e) {
    MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
    jsonView.setExtractValueFromSingleKeyModel(true);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("code", e.getErrorCode().getNumber());
    if (e.getMessage() != null) {
        map.put("message", e.getMessage());
    } else {
        map.put("message", "System Error");
    }
    map.put("exMessage", e.getPropertyMap());
    return new ModelAndView(jsonView, map);
}
 
開發者ID:edgar615,項目名稱:javase-study,代碼行數:20,代碼來源:ResponseMessage.java

示例5: success

import org.springframework.web.servlet.view.json.MappingJackson2JsonView; //導入方法依賴的package包/類
/**
 * 根據參數返回視圖
 *
 * @return 視圖
 */
public static ModelAndView success() {
    MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
    jsonView.setExtractValueFromSingleKeyModel(true);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("message", "success");
    // map.put("code", 500);
    return new ModelAndView(jsonView, map);
}
 
開發者ID:edgar615,項目名稱:javase-study,代碼行數:14,代碼來源:ResponseMessage.java


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