首页 » 日积月累 » 正文

springmvc 4+支持jsonp跨域请求

添加一个切面实现第jsonp的支持

package org.springrain.business.web;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice;

@ControllerAdvice(basePackages = "org.springrain.business.web.front") 
public class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
    public JsonpAdvice() {
        super("callback", "jsonp");
    }
}