本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}