Home  >  Article  >  Web Front-end  >  Reasons why jsp failed to load css

Reasons why jsp failed to load css

藏色散人
藏色散人Original
2020-12-14 09:36:532803browse

The reasons why jsp fails to load css: 1. The syntax of the css file is wrong; 2. The encoding of the css file is wrong; 3. The path to load the css file is wrong; 4. The filter is set; the solution: 1. Check css syntax; 2. Save the css file as UTF8 format; 3. Set the correct css path, etc.

Reasons why jsp failed to load css

The operating environment of this tutorial: windows7 system, css3&&jsp2.2 version, thinkpad t480 computer.

What are the reasons why jsp fails to load css?

Possible reasons are:

  • css file syntax error

  • css file encoding error

  • The path to load the css file is incorrect

  • Filter is set

Solution:

Method 1 : Check the css syntax and use online css code detection to check errors

Method 2: Use an editor that supports recoding and save the css file in UTF-8 format

Recommended: "css video tutorial

Method 3: Set the correct css path

(1) If your .jsp file is outside the WEB-INF folder, you can use a relative path

Reasons why jsp failed to load css

(2) If your .jsp file is in the WEB-INF folder, you must use the absolute path and add this ${pageContext.request.contextPath}

Reasons why jsp failed to load css

Method 4: Set the filter to intercept the request path to the corresponding file. For example, I filter jsp files, so my xml part is configured as follows:

<filter-mapping>
    <filter-name>login</filter-name>
     <url-pattern>/.jsp</url-pattern>
</filter-mapping>

For more technical articles related to CSS3, please visit the CSS3 Q&A column to learn!

The above is the detailed content of Reasons why jsp failed to load css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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