Servlet in the garbage problems and solutions

Local and solutions garbled related to the Servlet

Suppose now that there is a form form, garbled problem when we were in the text box to enter text, if not treated, there will be

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="registerServlet" method="POST">
		姓名:<input type="text" name="name"><br>
		年龄:<input type="text" name="age"><br>
		<input type="submit" value="注册">
	</form>
</body>
</html>

 

POST submission and submit the GET method causes of garbled

 

 

 

 

 

1.POST submission

 

<! - set request body character encoding, decoding server will follow when decoding UTF-8 
, but this way the request for the GET method is not applicable because the only effect on the body of the request ->
request.setCharacterEncoding("UTF-8");

 

  

 

Guess you like

Origin www.cnblogs.com/lijie0609/p/11825000.html