Today encountered a very strange problem, the front desk Ajax write URL address clearly and controller requestmapping address match, but has been reported 404 error. Later, compared with other methods, it was found that there was no annotated @responsebody. Plus, it's normal after that.
@ResponseBody annotation means direct output, so I always thought that only with the output content, always think it should be the first match the address, and then match the right, the execution method again output content, it seems not so.
Also note the two ways to submit a foreground table:
①
$.ajax ({ URL: "Your_url", data:$ ("#Form"). Serialize (), type: "Post", success: function(data) { if (data.code== "0") alert ("Success"), Else alert ("Failure"
The data in the table is serialized, the data type is not specified as JSON, the corresponding method can not be added @requestbody when the parameters are accepted;
② the second method is relative to the first method, the data in the table is converted to JSON, the data format is also specified as JSON, the corresponding method must be added @requestbody annotations when receiving parameters;
Obviously the first one is simpler. Both methods will report 503 (incorrect data format) if there is no good docking.
Ajax SPRINGMVC Controller report 404 error and form submission