servlet接受参数
格式:key=value
Sting value=request.getParameter("key")
例如: http://localhost/day09/hello?username=tom
request.getParameter("username")就可以获取tom值
回写内容:
response
response.getWriter().print("success");
处理响应数据中文乱码:
resp.setContentType("text/html;charset=utf-8"); //建议大家放在方法中的第一行
WebContent目录下 html文件代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="http://localhost:8080/webtwo/request?username=tom">_请求参数</a>
</body>
</html>
WEB-INF目录下 web.xml代码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSch