如Restlet文档中所述,它具有名为"tunneling"的功能。 RESTEasy中是否也存在此功能?
答案 0 :(得分:0)
下面的Servlet通过委托来自请求的“method”参数来支持“隧道”。
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
public class TunnelingDispatcher extends HttpServletDispatcher {
@Override
protected void service(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws ServletException,
IOException {
String method = httpServletRequest.getParameter("method");
if (method == null) {
method = httpServletRequest.getMethod();
} else {
method = method.toUpperCase();
}
service(method, httpServletRequest, httpServletResponse);
}
}