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