Gleb Kogtev
Gleb Kogtev

Reputation: 111

Cannot load CSS file Java Spring

I have the following project structure.

Project Structure
transport-servlet.xml

<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
<mvc:default-servlet-handler />

My jsp-page:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/style.css"/>">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <div class="header">
            <ul>
                <li><a href="index">Главная</a></li>
                <li><a href="transportTask">Решение задачи транспортного типа</a></li>
                <li style="float:right"><a class="active" href="about">Об авторе</a></li>
            </ul>
        </div>
        <br><br>
    </body>
</html>

Can anybody help me please?
I don't know, why my css file is not loading.
Thank you in advance.

Upvotes: 0

Views: 400

Answers (1)

Gleb Kogtev
Gleb Kogtev

Reputation: 111

I solved my problem by adding this lines in my web.xml:

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>

Upvotes: 1

Related Questions