色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

zuul怎么根據請求方式

阮建安2年前15瀏覽0評論

zuul怎么根據請求方式?

1、可以考慮一下繼承抽象過濾器的方式:com.netflix.zuul.ZuulFilter。關鍵代碼如下圖所示:

2、完整代碼如下:

package cn.jijicai.springboot;

import com.netflix.zuul.ZuulFilter;

import com.netflix.zuul.context.RequestContext;

import org.springframework.http.HttpMethod;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

@Component

public class RouteFilter extends ZuulFilter {

/**

* 過濾器的邏輯

*/

@Override

public Object run() {

//獲取當前請求上下文

RequestContext ctx = RequestContext.getCurrentContext();

//取出當前請求

HttpServletRequest request = ctx.getRequest();

HttpServletResponse response = ctx.getResponse();

try {

if (HttpMethod.GET.name().equals(request.getMethod())) {// GET請求

response.sendRedirect("/path1");

} else if (HttpMethod.POST.name().equals(request.getMethod())) {// POST請求

response.sendRedirect("/path2");

}

} catch (IOException e) {

e.printStackTrace();

}

return null;

}

@Override

public boolean shouldFilter() {

return false;

}

@Override

public String filterType() {

return null;

}

@Override

public int filterOrder() {

return 0;

}

}

java獲取post,zuul怎么根據請求方式