首页 > Web开发 > 详细

url提交参数类

时间:2019-03-10 17:27:57      阅读:128      评论:0      收藏:0      [点我收藏+]

url提交参数类

type
  /// <summary>
  /// 准备url
  /// </summary>
  TynUrl = class
  private
    FUrl, FCommand: string;
    FParams: TStringList;
    function GetText: string;
  public
    constructor Create;
    destructor Destroy; override;
    property url: string read FUrl write FUrl;
    property command: string read FCommand write FCommand;
    property params: TStringList read FParams write FParams;
    property text: string read GetText;
  end;

  

{ TynUrl }

constructor TynUrl.Create;
begin
  FParams := TStringList.Create;
end;

destructor TynUrl.Destroy;
begin
  FreeAndNil(FParams);
  inherited;
end;

function TynUrl.GetText: string;
var
  i: Integer;
  s: string;
begin
  Result := FUrl + ‘/‘ + FCommand;
  for i:=0 to FParams.Count -1 do
  begin
    if i = 0 then
      s := s + FParams.Names[i] + ‘=‘ + TNetEncoding.URL.Encode(FParams.ValueFromIndex[i])
    else
      s := s + ‘&‘ + FParams.Names[i] + ‘=‘ + TNetEncoding.URL.Encode(FParams.ValueFromIndex[i]);
  end;
  Result := Result + ‘?‘ + s;
end;

  

url提交参数类

原文:https://www.cnblogs.com/hnxxcxg/p/10505828.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!