<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
   <!--<form action="testRequestBody" method="post">   -->
   	<form action="test1" method="post"> 
   		<input name="username" value="haha" />
   		<input name="password" value="123456" />
   		<input type="submit" />
   	</form>
  </body>
</html>

 

/**
	 *  @RequestBody:请求体,  获取一个请求的请求体
	 */
	@RequestMapping("/testRequestBody")
	public String testRequestBody(@RequestBody String body){
		System.out.println("请求体:"+body);
		return "success";
	}

/**
	 *  如果参数位置写HttpEntity<String> entity
	 *  比@RequestBody强大的是,可以获取请求头
	 */
	@RequestMapping("/test1")
	public String test1(HttpEntity<String> entity){
		System.out.println("请求体:" + entity);
		return "success";
	}