SWI-Prolog CGI cgi_get_form(Arguments)网页隐藏表格

时间:2012-05-25 12:43:50

标签: forms list web prolog swi-prolog

我在使用SWI-Prolog的CGI库传递input type =“hidden”表单时遇到问题。具体来说,我做了:

<form id="frmCGIPrologIni" name="frmCGIPrologIni" method="post" action="http://localhost/cgi-bin/x.pl"> <p><input type="hidden" name="initial" value="ini" /> <input class="submit" type="submit" value="Start" /> </p></form>

当程序x.pl调用cgi_get_form(Arguments)时,参数应该是Name(Value)项的列表,i,e:[Name,Value],所以它应该是[initial(ini)]。

但是当我使用它时它会说:ERROR:= .. / 2:参数没有充分实例化

print_args([]).
print_args([F|T]) :- % with Arguments
    F =.. [Name, Value], % and should continue doing things

我尝试使用write(Arguments)手动打印它,我得到的是:_L160,打印第一个元素是:_G472和write_canonical(Arguments)返回:{{1 }}

我也试过使用method =“get”来检查它并正确打印URI '.'(_,_)所以我想这不是提交问题,而是处理cgi_get_form(Arguments)。

我第一次运行'http://localhost/cgi-bin/x.pl':

http://localhost/cgi-bin/x.pl?initial=ini

问题是第二次。这次调用相同的程序有Arguments所以它不打印消息,到这里一切都很好。然后经历真实并继续。那是我尝试用之前解释的结果(cgi_get_form(Arguments), (Arguments = []) -> ( format('<p>Print this as the index.</p>~n', []), ) ; true, % and it works well because there are no Arguments the first time write('<p>'), write(Arguments), write('</p>'), nl, % and print other things )写(参数)的时候。结果应该是表格传递的数据。

关于什么是问题的任何想法?

1 个答案:

答案 0 :(得分:0)

你试过吗

print_args([F|T]) :- % with Arguments
    F =.. [Name | Value], % and should continue doing things