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