本文整理汇总了Java中org.springframework.http.HttpStatus.PAYLOAD_TOO_LARGE属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.PAYLOAD_TOO_LARGE属性的具体用法?Java HttpStatus.PAYLOAD_TOO_LARGE怎么用?Java HttpStatus.PAYLOAD_TOO_LARGE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.PAYLOAD_TOO_LARGE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCacheEntries
/**
* Get all cache entries. If cache has more than 100 items, it will respond with
* <b>413 Request Entity Too Large</b> http status code.
*
* @return cache entries map.
*/
@RequestMapping(value = "/cache/entries", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Map<String, Object>> getCacheEntries() {
// Do a cache maintenance first before getting the size
cache.instance().cleanUp();
long size = cache.instance().size();
Map<String, Object> stat = new LinkedHashMap<>(3);
if (size > 100) {
stat.put("status", "Too many cache entries (size=" + size + ")");
return new ResponseEntity<>(stat, HttpStatus.PAYLOAD_TOO_LARGE);
}
stat.put("status", "ok");
stat.put("size", size);
Map<String, String> map = cache.instance().asMap();
Map<String, Object> entries = new HashMap<>(map.size());
for (String key : map.keySet()) {
entries.put(key, map.get(key));
}
stat.put("entries", entries);
return new ResponseEntity<>(stat, HttpStatus.OK);
}
示例2: handleMultipartError
@ExceptionHandler(MultipartException.class)
@ResponseStatus(HttpStatus.PAYLOAD_TOO_LARGE)
public ModelAndView handleMultipartError(HttpServletRequest req, MultipartException exception)
throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("page", new Page("mzTabValidator", versionNumber, gaId));
mav.addObject("error", exception);
mav.addObject("url", req.getRequestURL());
mav.addObject("timestamp", new Date().toString());
mav.addObject("status", 413);
mav.setViewName("error");
return mav;
}