Http 错误:"status":404,"error":"Not Found","message":"No message available”,”path":""

When debugging the code, the front page reported an error:

1 {"timestamp":"2019-09-02T02:55:45.555+0000","status":404,"error":"Not Found","message":"No message available”,”path":"/order/createorder"}

  The reason this bug occurs because made a more low-level error. . . But I think the analysis of ideas to solve the problem can still learn, to sum up here.

  The front page displays an error message, but I do not have a back-end program error message, not even an exception is thrown, and the relevant data is successfully written to the database, order information into the database, reducing merchandise inventory, increase sales, all data back-end logic is no problem, but why front-end error it? So I fixed the problem on the front end of the html file, go back to troubleshoot front-end code, open chrome inspection, refresh the page, add breakpoints, refresh, see the value:

 

  State status is indeed found success, variable data is completely correct, how, after a morning of investigation, the front end looks like there is nothing wrong. A closer analysis at the wrong front page of the newspaper, 404, not found, "path": "/ order / createorder", do the back-end control level code is wrong, leading to the front page in response to the results did not find the right path. Go back and check, Sure, in the annotation control layer above the drain @ResponseBody annotation method.

@ResponseBody

Let's look at how to add this comment

  The course documentation states that this annotation serves the function to: ensure that the result will be written to the HTTP response by an HTTP Message Converter (instead of an MVC View).

  The annotation means is that the returned value of the method will constitute the body of the HTTP response.

  The returned value of the method will constitute the body of the HTTP response.

  He said means is a, is a method for annotating @ResponseBody, the returned result indicates that the method is written directly to the body of the HTTP response (Http Response Body) In. I code before the control layer has a return value, the general type of CommonReturnType return type, the return value I is removed, the method to void, without any return value, although the front end of the commissioning, the various data is still normal, but the front page for less than the control layer method's return value, no content in the response body, resulting in front page click on the button does not have any phenomenon, although at this time the back-end logic is correct, database warehousing operations have achieved. So here I have a return value to the method, and through comment forms will be returned in value to the Http response body. Without this comment, it will throw an exception responseText information above.

 

Ref1

Ref2 

 

Guess you like

Origin www.cnblogs.com/dogeLife/p/11447394.html