websRedirect(wp,"index.asp"); 这个函数完了之后下面就最好不要进行 websWrite();操作了,如果没有其它非要处理的数据最好在之后 紧跟return;以结束函数。
比如: int func(web_t wp, char * p1, char *p2) { int a,b; if(p1 == NULL || p2 == NULL) { websRedirect(wp, "error.html"); } websWrite(wp, T("%d"), a+b); return 0; } 象这样的函数,如果没出错那么OK,万事大吉;如果p1为空,那么这个web就会崩溃。 出现类似“This document has moved to a new <a href=\"%s\">location</a>.\r\n\ 这个很理解吧, websRedirect(wp, "error.html");已经转到另一个页面了,但 websWrite(wp, T("%d"), a+b);不是这个新页面所请求的东西,出现错误。而且这种错误不容易发现。因为你的程序看上去一切正常。所以提醒大家一下: int func(web_t wp, char * p1, char *p2) { int a,b; if(p1 == NULL || p2 == NULL) { websRedirect(wp, "error.html"); return -1; } websWrite(wp, T("%d"), a+b); return 0; } |
|