restful put the request (pit), and do effect parameters HttpServletRequest

/ **
* If the form is sent directly ajax = PUT request
* encapsulated data
* the Employee
* [= 1014. empId, empName = null, Gender = null, null = In Email, dId = null]
*
* Question:
* the request body has transactions;
* Employee object but not on the package;
* Update the emp_id = 1014. WHERE tbl_emp;
*
* reasons:
* the Tomcat:
*. 1, the data request body, a package map.
* 2, request.getParameter ( "empName" ) will be the value from this map.
* 3, SpringMVC POJO package when the object.
* Will POJO value of each attribute, request.getParamter ( "In Email");
* AJAX murder initiated by sending a PUT:
* PUT request, data request body, request.getParameter ( "empName") get
* Tomcat not see the data package PUT request body of a map, only the POST request form the package body to request only Map
* org.apache.catalina.connector.Request - parseParameters () (3111);
*
* Protected String parseBodyMethods = "POST";
* IF (getConnector () isParseBodyMethod (getMethod ())!.) {
Success = to true;
return;
}
*
*
* solutions;
* We need to be able to support sending the request PUT like direct also encapsulated request data volume
* 1 disposed on HttpPutFormContentFilter;
* 2, his role; data request body packed into a parse map.
* 3, request repackaged, request.getParameter () is rewritten, the data will be taken from the map own package
* employees update method
* @param Employee
* @return
* /
@ResponseBody
@RequestMapping (value = "/ EMP /{empId}",method=RequestMethod.PUT)
public Msg saveEmp (the Employee Employee, the HttpServletRequest request) {
System.out.println ( "the value of the request body:" + request.getParameter ( "Gender"));
the System. out.println ( "
employeeService.updateEmp(employee);
return Msg.success() ;
}

 

Employee added in the parameters, request will automatically encapsulated data request to the employee

Guess you like

Origin www.cnblogs.com/w123w/p/11695641.html