目录
通过原生ServletAPI获取参数
我们可以将 HttpServletRequest 参数设置为控制器方法的形参,然后 DispatcherServlet 就会自动将当前请求的请求报文对象传入
测试:获取 test_param.html 页面提交的表单数据并打印到控制台上
test_param.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" xmlns:th="http://thymeleaf.org">
<title>测试请求参数</title>
</head>
<body>
<h1>测试请求参数</h1>
<form th:action="@{/test1}">
<p>username: <input type="text" name="username"></p>
<p>password: <input type="text" name="password"></p>
<input type="submit" value="提交">
</form>
</body>
</html>