Scenario description, using Spring MVC framework to save data, and using firefox's firebug to track discovery 404 Not Found.
Analysis: The background did not print any error logs, and the problem could not be analyzed.
Solution (provided by my friend)
Add a red section of the configuration file to the spring-mvc.xml configuration file.
Add ControllerAdviceTest.java file under controller (Note: it must be under controller, because component-scan is configured in spring-mvc.xml)
Run the background again to output the following error log
It is obvious that there is a problem with the object name, so the problem is solved. Attachment: Attach the source code of ControllerAdviceTest.java (can't you add a compressed package? Please modify the bag name yourself)
package com.snake.controller; import org.apache.log4j.Logger; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.context.request.NativeWebRequest; @ControllerAdvice public class ControllerAdviceTest { protected static Logger logger = Logger.getLogger(ControllerAdviceTest.class); @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public String processUnauthenticatedException(NativeWebRequest request,Exception e) { logger.error(e.getMessage()); return "viewName"; //Return a logical view name} }The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.