1、前段代码:
<form action="http://localhost:8080/product/add" method="post">
<p>s_type<input type="text" name="s_type"/></p>
<p><input type="submit" value="Submit" /></p>
</form>
2、后端获取:
@RequestMapping(value = "/fancy/{add}", method = RequestMethod.POST)
public String addFancy(HttpServletRequest request) {
System.out.println(request.getParameter("s_type"));
return "fancy";
}
通过
HttpServletRequest request
的
getParameter
方法根据表单 name 属性获取表单的值