无法在Spring Mavenized项目中加载CSS [英] Unable to load CSS in Spring Mavenized project

查看:155
本文介绍了无法在Spring Mavenized项目中加载CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一个CSS路径的问题。
这是一个Spring Maven项目的文件结构。

I have a problem with CSS path in my project. This is the file structure of a Spring Maven project.

在jsp页面中我写道:

In jsp page I wrote:

<link rel="stylesheet" href="/Treninky/css/bootstrap.css" />

但它仍然不工作。我找不到解决方案。
任何人都可以帮助我?

But it still does not work. I can't find a solution. Could anyone help me?

推荐答案

将此文件添加到web.xml

add this to your web.xml

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

,最好将css移动到另一个目录,例如 src / main /资源或不在WEB-INF

and it's better to move your css to another directory like src/main/resources or somewhere that not in WEB-INF

这篇关于无法在Spring Mavenized项目中加载CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆