浏览代码

增加返回值

yaobo 7 年之前
父节点
当前提交
d2c789224e
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/main/java/cn/efunbox/audio/aop/AdminInterceptor.java

+ 4 - 1
src/main/java/cn/efunbox/audio/aop/AdminInterceptor.java

@@ -4,9 +4,11 @@ import cn.efunbox.audio.consts.Consts;
 import cn.efunbox.audio.service.AdminService;
 import cn.efunbox.audio.utils.ApiCode;
 import cn.efunbox.audio.utils.HttpUtil;
+import org.apache.http.HttpStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.http.HttpMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.servlet.HandlerInterceptor;
 import org.springframework.web.servlet.ModelAndView;
@@ -29,7 +31,8 @@ public class AdminInterceptor implements HandlerInterceptor {
     @Override
     public boolean preHandle(HttpServletRequest request,
                              HttpServletResponse response, Object handler) throws Exception {
-        if(request.getMethod().equalsIgnoreCase("OPTIONS")){
+        if(HttpMethod.OPTIONS.matches(request.getMethod())){
+            response.setStatus(HttpStatus.SC_OK);
             HttpUtil.responseOk(request, response);
             return false;
         }