我正在尝试在基于spring框架的WEB应用程序中使用Openlayer。我需要在tomcat上使用cgi代理。我按照installing-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 & 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>'
答案 0 :(得分:1)
您已将CGIServlet
映射到/cgi-bin/*
并将DispatcherServlet
映射到/app/*
- 毫不奇怪,<contextPath>/app/cgi-bin/proxy.cgi
的请求由Spring而不是CGI处理。
请尝试/pcms/cgi-bin/proxy.cgi
。
答案 1 :(得分: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”;