当前位置: 首页>>代码示例>>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;未经允许,请勿转载。