In jsp, we often read data from the database and return to the client, but we often experience garbled code during production, so we can use <%("UTF-8");%> to ensure the correct output of Chinese. Let's give an example below.
Before we want to catch the value of the form or print the database data, put <%("UTF-8");%> in front of them. Then, the form must be submitted by post, that is, method="post", so that it can avoid garbled code. Please see below:
<%("UTF-8");%>
<form action="" method="post">
Name: <input type="text" name="name"/>
<br/>
Gender: <input type="text" name="sex" />
<%
String name=("name");
String sex=("sex");(name);
(sex);
%>
</form>
Or sometimes when a user logs in, we need to use the user name or password on a certain page. We can remember it by using the following method. You can call it at will on other pages, such as:
<form action="" method="post">
Username: <input type="text" name="name"/>
<br/>
Password: <input type="password" name="password" />
<form/>
String name=("name");
String password=("password");
("names",name);
("passwords",password); Password and username are remembered in this way, and can also be called at will, as follows
(“names");
("passwords");
<%
((“names"));
((“passwords")
%>
This will output the value of the text box
Before we want to catch the value of the form or print the database data, put <%("UTF-8");%> in front of them. Then, the form must be submitted by post, that is, method="post", so that it can avoid garbled code. Please see below:
Copy the codeThe code is as follows:
<%("UTF-8");%>
<form action="" method="post">
Name: <input type="text" name="name"/>
<br/>
Gender: <input type="text" name="sex" />
<%
String name=("name");
String sex=("sex");(name);
(sex);
%>
</form>
Or sometimes when a user logs in, we need to use the user name or password on a certain page. We can remember it by using the following method. You can call it at will on other pages, such as:
Copy the codeThe code is as follows:
<form action="" method="post">
Username: <input type="text" name="name"/>
<br/>
Password: <input type="password" name="password" />
<form/>
String name=("name");
String password=("password");
("names",name);
("passwords",password); Password and username are remembered in this way, and can also be called at will, as follows
(“names");
("passwords");
<%
((“names"));
((“passwords")
%>
This will output the value of the text box