0

我正在尝试在基于 spring 框架的 WEB 应用程序中使用 Openlayer。我需要在 tomcat 上使用 cgi 代理。我按照这里的说明安装-a-cgi-on-tomcat。它适用于一个简单的 Web 应用程序。但是当我尝试使用 Spring MVC 实现它时,我在访问 cgi 文件时遇到了问题。我收到了警告信息。

 WARN org.springframework.web.servlet.PageNotFound:962 - No mapping found for HTTP request with URI [/pcms/app/cgi-bin/proxy.cgi] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'

我尝试了很多方法,但我没有弄清楚如何访问WEB-INF\cgi目录下的proxy.cgi文件。请帮忙。谢谢。附上web.xml的内容。

  <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Property &amp; Configuration Management System</display-name>
  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>pcms.root</param-value>
  </context-param>
   <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  </listener>
  <listener>
    <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
  </listener>
  <listener>
    <listener-class>com.pb.redline.listener.MTAServletContextListener</listener-class>
  </listener>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
            /WEB-INF/spring/web-application-context.xml
        </param-value>
  </context-param>
  <filter>
    <filter-name>openEntityManagerInViewFilter</filter-name>
    <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>openEntityManagerInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
  </filter>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
            </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/app/*</url-pattern>
  </servlet-mapping>

  <!-- proxy.cgi for openlayers -->
    <servlet>
        <servlet-name>cgi</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/cgi</param-value>
        </init-param>
         <init-param>
          <param-name>executable</param-name>
          <param-value>C:/Python26/ArcGIS10.0/python.exe</param-value>
        </init-param>
        <init-param>
          <param-name>passShellEnvironment</param-name>
          <param-value>true</param-value>
        </init-param>
         <load-on-startup>5</load-on-startup>
    </servlet>
        <servlet-mapping>
            <servlet-name>default</servlet-name>
            <url-pattern>/</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
            <servlet-name>cgi</servlet-name>
            <url-pattern>/cgi-bin/*</url-pattern>
    </servlet-mapping>

</web-app>'
4

2 回答 2

1

您映射CGIServlet/cgi-bin/*和映射DispatcherServlet/app/*- 请求<contextPath>/app/cgi-bin/proxy.cgi由 Spring 而不是 CGI 处理,这并不奇怪。

试试/pcms/cgi-bin/proxy.cgi吧。

于 2012-11-27T20:10:24.973 回答
0

答案是:您没有在 Tomcat 上安装或使用 cgi 代理。

cgi 适用于用作前端服务器的 apache 服务器或 IIS。Tomcat 可能坐在它后面。Apache的配置详解在:http: //tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html

请注意,OpenLayers 警告说它的 proxy.cgi 只是一个示例,可能没有足够好的检查来阻止它被利用,即它可能运行一些恶意脚本。

如果您仅在 Tomcat 上提供 OpenLayers 客户端页面,并且它包含来自其他 GeoServer 或 Mapserver 的图层,则可以使用代理 servlet 并将其指定为:

OpenLayers.ProxyHost = "服务于该页面的服务器上的 sevlet URL";

http://wiki.apache.org/tomcat/ServletProxy

https://svn.openxdata.org/Experimental/openXmapper/trunk/gwt-openlayers-server/src/main/java/org/gwtopenmaps/openlayers/server/GwtOpenLayersProxyServlet.java

于 2013-11-26T23:11:27.430 回答