Java Code Examples for org.springframework.web.bind.annotation.RequestMapping.produces()

The following are Jave code examples for showing how to use produces() of the org.springframework.web.bind.annotation.RequestMapping class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: spring-cloud-sample   File:   Source Code and License Vote up 5 votes
 * 判断是否需要输出json
 * @param request HttpServletRequest对象
 * @param handler HandlerMethod对象
 * @return 需要输出json返回true,否则返回false
protected boolean isJsonResponse(HttpServletRequest request, Object handler) {
    if (handler instanceof HandlerMethod) {
        RequestMapping requestMapping = ((HandlerMethod) handler).getMethodAnnotation(RequestMapping.class);
        return requestMapping.produces().length > 0 && requestMapping.produces()[0].contains("json");
    return false;