com.alibaba.fastjson.support.spring

Class JSONPResponseBodyAdvice

  • All Implemented Interfaces:
    org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice< Object>

    @Order(value=-2147483648)
     @ControllerAdvice
    public class JSONPResponseBodyAdvice
    extends Object
    implements org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>
    Created by SongLing.Dong on 7/22/2017.

    Wrap with the return object from method annotated by @ResponseJSONP in order to be serialized into jsonp format.

    url: /path/to/your/api?callback=functionName

    Since:
    Spring 4.2 when ResponseBodyAdvice is supported.

    In Spring 3.x, use method directly return a JSONPObject instead.

    See Also:
    JSONPObject, ResponseJSONP
    • Field Summary

      Fields  
      Modifier and Type Field and Description
      org.apache.commons.logging.Log logger 
    • Method Summary

      All Methods  Instance Methods  Concrete Methods 
      Modifier and Type Method and Description
      Object beforeBodyWrite(Object body, org.springframework.core.MethodParameter returnType, org.springframework.http.MediaType selectedContentType, Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> selectedConverterType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response) 
      void beforeBodyWriteInternal(JSONPObject jsonpObject, org.springframework.http.MediaType contentType, org.springframework.core.MethodParameter returnType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response) 
      boolean supports(org.springframework.core.MethodParameter returnType, Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType) 
    • Field Detail

      • logger

        public final org.apache.commons.logging.Log logger
    • Constructor Detail

      • JSONPResponseBodyAdvice

        public JSONPResponseBodyAdvice()
    • Method Detail

      • supports

        public boolean supports(org.springframework.core.MethodParameter returnType,
                                Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
        Specified by:
        supports in interface  org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>
      • beforeBodyWrite

        public Object beforeBodyWrite(Object body,
                                      org.springframework.core.MethodParameter returnType,
                                      org.springframework.http.MediaType selectedContentType,
                                      Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> selectedConverterType,
                                      org.springframework.http.server.ServerHttpRequest request,
                                      org.springframework.http.server.ServerHttpResponse response)
        Specified by:
        beforeBodyWrite in interface  org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>
      • beforeBodyWriteInternal

        public void beforeBodyWriteInternal(JSONPObject jsonpObject,
                                            org.springframework.http.MediaType contentType,
                                            org.springframework.core.MethodParameter returnType,
                                            org.springframework.http.server.ServerHttpRequest request,
                                            org.springframework.http.server.ServerHttpResponse response)

Copyright © 2012–2021 Alibaba Group. All rights reserved.