Chapter 1 List of errors encountered during development, Chapter 1 Development
List of errors encountered during development: (the list will be updated continuously)
1. http
404: The resource cannot be found. A strange problem in springmvc is listed.
Symptom:
- When we execute a method in controller, assume that the path on the class is "/mq" and the path on the method is "/addLog", then the access path is "localhost: 8080/mq/addLog "(Note: The project name can be omitted). After access, the Error 404"/mq/addLog "cannot be found?
Analysis:
- Why is the access path "/mq/addLog", but the error "/mq/addLog" is not found?
Cause:
- The return type of the method is void. In the method body, no information is manually returned to the client, such as a json string. -- This is not allowed by spring.
Solution:
- Change the return type of the method and return the corresponding data.
- The method type is still void, and the method body returns information to the client manually
406: Indicates that the client browser does not accept the MIME type of the requested page.
Symptom:
- Assume that in the above method, we return the boolean value in the method body and the return value of the method is also defined as boolean, and add @ ResponseBody to the method. At this time, this method is executed and 406 is returned.
Cause:
- We added @ ResponseBody to the method body. In fact, our actual intention is to return json to the front-end, but we didn't configure the json converter, So we threw a 406
Solution:
- Configure the json converter in the spring. xml file