CGI Perl脚本正在将HTML字符串(以及'content-type:text / html')打印到浏览器,而不是呈现它。怎么修? [英] CGI Perl script is printing the HTML (along with 'content-type: text/html') string to the browser rather than rendering it. How to fix?

查看:70
本文介绍了CGI Perl脚本正在将HTML字符串(以及'content-type:text / html')打印到浏览器,而不是呈现它。怎么修?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个perl CGI脚本,需要发送回一些HTML

I have a perl CGI script that needs to send back some HTML

print qq^Content-type: text/html\n\n
<HTML>
<HEAD>
<TITLE>some title</TITLE>
...
...
...
...
^:

我没有在浏览器中看到呈现的HTML,而是看到了整个HTML以及标签和纯文本中的 content-type行。以下是浏览器中的外观-

Instead of seeing the rendered HTML in the browser, I see the entire HTML along with the tags and the 'content-type' line in plain text. Below is how things look in the browser -

Content-type: text/html


    <HTML>
    <HEAD>
    <TITLE>some title</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" BACKGROUND="" onLoad=document.forms[0].elements[0].focus();>


推荐答案

此外,因为CGI脚本可以在没有网络的情况下调用服务器,只需手动调用脚本(如果对脚本很重要,请使用正确的参数/环境变量并查看输出。如eugene y所指示的那样,请求标头必须是CGI脚本的第一个输出,以便可以选择它们由服务器决定。

Also, as CGI scripts can be called without a web server, just call the script manually (with the right parameters / environment variables if they matter to the script and look at the output. As indicated by eugene y, the request headers must be the first output from the CGI script for them to be picked up by the server.

这篇关于CGI Perl脚本正在将HTML字符串(以及'content-type:text / html')打印到浏览器,而不是呈现它。怎么修?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆