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


Java HttpStatus.PAYLOAD_TOO_LARGE屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:28,代碼來源:OpampWsController.java

示例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;
}
 
開發者ID:nilshoffmann,項目名稱:jmzTab-m,代碼行數:13,代碼來源:ValidationController.java


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