liguiyuan112 发表于 2014-9-16 00:25:16

在ARM9 2440, .CGI文件在读取HTML的js和css文件时读取不了。

在ARM9开发板上,我已经实现用网页控制LED灯,为了让页面更好看,我就做了一个更好看的网页,却在main.cgi里面无法读取HTML文件的js和css文件。大家有什么好的方法吗?我目前知道有两种方法,但都不好使。第一种方法我觉得很愚蠢,因为我的网站内容是挺多的,这样就非常麻烦了,所以用这种方法。方法如下:
<html>
<head>
<title> just an example </title>
</head>
<body>
<form action= "/cgi-bin/cgitest" method="get">
<p>请在下面填入乘数和被乘数,按下确定后可以看到结果。</p>
<p><INPUT NAME ="m" SIZE= "5"></p>
<INPUT NAME="n"    SIZE="5"><BR>
<p><INPUT TYPE="SUBMIT" VALUE="确定"></p>
</form>
</body>

</html>
这是html页面

以下是cgi程序保存为cgitest.c。将其编译为可执行文件放入../cgi-bin/目录下即可。
# include <stdio.h>
# include <stdlib.h>


int main()
   {
      char *data;
      longm,n;
      
      printf("Content-Type:text/html \r\n\r\n");

      printf("<html> <head>\n");
      printf("<title> hello world</title> \n");
      printf("</head>\n");
      printf("<body> \n");
      printf("<h1> hello world </h1> \n");
      data = getenv("QUERY_STRING");
      if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)

      printf("< P >错误!输入数据非法。表单中输入的必须是数字。</p>");

      else

      printf("< P >%ld和%ld的成绩是:%ld。",m,n,m*n);
      printf("</body> </html> \n");
      return 0;   
   
   }


第二种方法就是把 main.html文件做成main_html文件(好像是把mian.html扩展名直接改为main_html就行了),但是不知道为什么加载不了js和css文件,花两天做的网站都不能用,感到郁闷啊。
第二种方法如下:


我也把自己的文件目录发上去吧。

页: [1]
查看完整版本: 在ARM9 2440, .CGI文件在读取HTML的js和css文件时读取不了。