In general, we will pass a URL to the server passed a lot of parameters, through the parameters to determine the corresponding processing, today is about to talk about
If you implement some functionality through URL parameters.
1. Jump into different interfaces via parameters
First we set up a TMS Web core project file.
In addition to the main page, we build two more pages, called the first page and the second page, respectively.
We can go directly to different pages with different URL parameters.
Do some processing in the project file.
var
s: string;
begin
Application.Initialize;
Application.AutoFormRoute: = true;
Application.MainFormOnTaskbar: = True;
if HasQueryParam (‘page’, s) then
begin
if s = ‘one’ then
Application.CreateForm (Tonepagef, onepagef);
if s = ‘two’ then
Application.CreateForm (TtwopageF, twopageF);
end
else
Application.CreateForm (Tmainf, mainf);
Application.Run;
end.
Note that the unit WEBLib.WebTools should be added to the uses section.
We now run this example
Without adding parameters, directly display the main page
Let's try it with parameters
You can see that we jump directly to the page we need through the URL parameter.
2. Pass parameters to the current page through URL parameters
Put the corresponding control on the main page
Add the corresponding code to the formshow event
procedure Tmainf.WebFormShow (Sender: TObject);
var
s: string;
begin
if HasQueryParam (‘arg1’, s) then
WebLabel2.Caption: = s
else
WebLabel2.Caption: = ‘‘ ‘;
if HasQueryParam (‘arg2‘, s) then
WebLabel5.Caption: = s
else
WebLabel5.Caption: = ‘‘ ‘;
end;
Run this program
Normal display of incoming parameters
Chinese characters can also be processed normally.
Off-topic, because the URL parameter is a very convenient way of SQL injection, so in the actual program processing
When you use URL to spell SQL, you must pay attention to the validity of the input parameters first. You cannot directly use the input parameters to spell SQL.
In addition, use SQL parameters to process input values whenever possible.
tms web core passes parameters via URL