Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Spring MVC中访问proxy.cgi文件_Spring_Tomcat_Cgi - Fatal编程技术网

如何在Spring MVC中访问proxy.cgi文件

如何在Spring MVC中访问proxy.cgi文件,spring,tomcat,cgi,Spring,Tomcat,Cgi,我试图在基于spring框架的WEB应用程序中使用Openlayer。我需要在tomcat上使用cgi代理。我是按照这里的指示来的。它与一个简单的web应用程序一起工作。但是当我试图用SpringMVC实现cgi文件时,我遇到了访问cgi文件的问题。我收到了警告信息 WARN org.springframework.web.servlet.PageNotFound:962 - No mapping found for HTTP request with URI [/pcms/app/cgi-b

我试图在基于spring框架的WEB应用程序中使用Openlayer。我需要在tomcat上使用cgi代理。我是按照这里的指示来的。它与一个简单的web应用程序一起工作。但是当我试图用SpringMVC实现cgi文件时,我遇到了访问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>'

地产及;配置管理系统
WebApprotKey
根
log4jConfigLocation
/WEB-INF/log4j.properties
org.springframework.web.util.Log4jConfigListener
org.springframework.web.context.ContextLoaderListener
com.pb.redline.listener.MTAServletContextListener
上下文配置位置
/WEB-INF/spring/WEB-application-context.xml
OpenEntityManager视图过滤器
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
OpenEntityManager视图过滤器
/*
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
编码过滤器
org.springframework.web.filter.CharacterEncodingFilter
编码
UTF-8
编码过滤器
/*
URL重写过滤器
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
URL重写过滤器
/*
SpringMVC调度程序Servlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
1.
SpringMVC调度程序Servlet
/应用程序/*
cgi
org.apache.catalina.servlets.CGIServlet
调试
0
cgiPathPrefix
WEB-INF/cgi
可执行
C:/Python26/ArcGIS10.0/python.exe
密码环境
真的
5.
违约
/
cgi
/cgi箱/*
'

您将
CGIServlet
映射到
/cgi-bin/*
并将
DispatcherServlet
映射到
/app/*
——对
/app/cgi-bin/proxy.cgi
的请求由Spring而不是由cgi处理,这并不奇怪


请改为尝试
/pcms/cgi-bin/proxy.cgi

答案是:您没有在Tomcat上安装或使用cgi-proxy

cgi用于用作前端服务器的apache服务器或IIS。雄猫可以坐在它后面。Apache的配置详见:

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

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

OpenLayers.ProxyHost=“服务于此页面的服务器上的sevlet URL”


我使用了这个
OpenLayers.ProxyHost=“/pcms/cgi-bin/proxy.cgi?url=“
”;它会自动映射到
/pcms/app/cgi-bin/proxy.cgi
。然后应用程序无法访问cgifile@Alex:我看到您使用了
UrlRewriteFilter
。您需要将
/cgi-bin/*
的排除项添加到其配置中。谢谢。我在urlrewrite.xml中添加了排除规则。它起作用了。