2011-08-05 92 views

回答

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); 
} 

}