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;