我的配置如下:
<servlet>
<servlet-name>cgi</servlet-name>
servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>1</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></param-value>
</init-param>
<param-name>passShellEnvironment</param-name>
<param-value>true</param-value>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
还要添加
但是当我访问我的cgi的url时,它会将内容显示为文本,不会在cgi中执行命令,请你指出会发生什么?
答案 0 :(得分:0)
bash中的HTTP响应。请注意第二行。区分http标头和有效负载
非常重要#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Hello World</title></head>"
echo "<body>"
echo "Hello World!"
echo "</body></html>"