What should I do if springmvc does not load css?

藏色散人
Release: 2020-12-22 09:44:17
Original
2453 people have browsed it

The solution to springmvc not loading css: first add the default configuration to the SpringMVC configuration as "<mvc:default-servlet-handler/>"; then add the configuration "

What should I do if springmvc does not load css?

The operating environment of this tutorial: Windows7 system, css3&&Spring5.x version, this method is suitable for all brands of computers .

Recommended: "css Video Tutorial"

SpringMVC cannot load js, css and other static resource files, and an exception cannot be found when running. How to solve this?

Since SpringMVC supports more elegant Rest-style URLs, and url-patten is configured to support all patterns, static resources (css, js, html, etc.) will also be matched. Once the matching fails The console will throw a URI matching exception.

In this case, you need to add the default configuration in the SpringMVC configuration

<mvc:default-servlet-handler/>
Copy after login

After adding the above configuration, the original RequestMapping will be abnormal again. At this time, you need to add the following configuration

<mvc:annotation-driven></mvc:annotation-driven>
Copy after login

Note that this configuration generally needs to be added during the development process of SpirngMVC.

The above is the detailed content of What should I do if springmvc does not load css?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template