Java实现OpenLayers跨域代理程序(2)

/**
 * This is a transparent HTTP proxy written in Java that is similar to the proxy in
 * the OpenLayers examples, which is written in Python. These proxies are used
 * to circumvent browser restrictions on cross-domain requests with Javascript.
 * </p>
 * <p>
 * To use the proxy you need to 1) configure the proxy servlet in your web.xml
 * and 2) use OpenLayers.setProxyHost to set the url-path to the proxy. If the
 * proxy is configured to listen to the url-pattern '/gwtOpenLayersProxy/*' then
 * the proxy host should be set to 'gwtOpenLayersProxy?targetURL='.
 * </p>
 * Initial code for this proxy is based upon <a href=https://www.linuxidc.com/Linux/2014-01/
 * "?format=diff&new=8099">the
 * following code</a><br />
 * see also <a href=https://www.linuxidc.com/Linux/2014-01/
 * ""
 * title="this networking tutorial">this networking tutorial</a>
 * <p>
 */
@SuppressWarnings("serial")
public class GwtOpenLayersProxyServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        {
                processRequest(request,response);
        }

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        {
                processRequest(request, response);
        }

private void processRequest(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, IOException {

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/c5c9f3449647f0e7e9590e9bffae1383.html