Spring MVC 404 Not Found Error-free log solution

Source: Internet
Author: User

Scene description, using the Spring MVC framework for data preservation, using Firefox's firebug trace to find 404 Not Found.


Analysis: No error logs are printed in the background and the problem cannot be analyzed.


Solutions (provided by my friends)

Add a red section of the configuration file to the Spring-mvc.xml configuration file.


Add the Controlleradvicetest.java file under controller (note: must be under controller because Component-scan is configured in Spring-mvc.xml)



Run the background output the following error log again


It is clear that there is a problem with the object name and the problem is resolved. Attachment: Attach Controlleradvicetest.java Source code (Cannot add compressed package?) Please change 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; @ControllerAdvicepublic 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"; Returns a logical view name    }}



Spring MVC 404 Not Found Error-free log solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.