0
正如Restlet文檔中所述,它具有名爲"tunneling"的功能。這個功能是否也存在於RESTEasy中?RESTEasy是否支持隧道?
正如Restlet文檔中所述,它具有名爲"tunneling"的功能。這個功能是否也存在於RESTEasy中?RESTEasy是否支持隧道?
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);
}
}