A stupid mistake (helpless) or a stupid mistake (

Source: Internet
Author: User

A stupid mistake (helpless) or a stupid mistake (

Today, it took me half a day to solve the path problem. Because projects use relative paths, but there are too many folders nested, the path is faulty, so I want to get the path on the page. I tried a lot of methods and didn't use it. I finally used the mvc interceptor, it took me two hours to get out.

The source of the pitfall is this:

<Mvc: interceptors> <mvc: interceptor> <mvc: mapping path = "/**"/> <bean class = "com. muke. springMVC. interceptors. pathInterceptors "/> </mvc: interceptor> </mvc: interceptors>

The interceptor was deleted in My anger. There is nothing in it, that is, retrieving the context path from the request and placing it in modelAndView. addObject.

This is the code found online.

As soon as it was running, the console was blown up as soon as it entered the page, and the interceptor went in, but the following reported a null pointer, and then the path on the page was wrong, the url also adds the name and value that I added.

At first, I thought it was modelAndView, which caused the url rewriting to lead to the disorder of null pointers and page paths. So I learned this object and read it for a long time, I think it's correct. Why is it a null pointer? Why have I repeatedly accessed it? I just requested it once. It was not known until the end because of the interceptor.

On the page, css js and other requests are also intercepted, but it is a request for static resources such as css js, so the upstream and downstream requests cannot be obtained, so the path is empty, when it is put in, a null pointer is reported, and so many interceptors are requested.

This is really enough. The last time is also a pitfall of static resources. This time is also true. Stupid

Related Article

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.