分享

goahead常用函数注意事项

 每天学一点7 2013-11-15

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\
  Please update your documents to reflect the new location ”的错误提示,然后goahead死掉。

这个很理解吧, 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;

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多