問題は一般的ですが、私は多くのソリューションを試しましたが、何も私のためには機能しません。 私は春にはかなり新しいので、私はいくつかのことを理解していないかもしれません。Java Spring-MVCアプリケーションは、CSSおよびJSファイルを送信しません。エラー404
私は次のファイル構造を持っている:ページ内の
私のリンクは、このようThymeleafでテンプレート化されています
<link rel="stylesheet" th:href="@{css/bootstrap.css}" type="text/css"/>
また、HTMLの頭の中で属性があります。
[OK]を、そして私の春-context.xmlには、次のとおりです。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--to pick up all annotation in the package-->
<context:component-scan base-package="langquiz"/>
<mvc:annotation-driven />
<mvc:resources mapping="/css/**" location="/css/"/>
</beans>
私は(場所を書い= "/テンプレート/ CSS /" または場所= "CSS /" のように)マッピングにいくつかの操作を試してみましたまた、コンフィグレーションクラスでリソースハンドラを試しました。しかし何も役に立たない。
ありがとうございました!
UPD: は
<mvc:resources mapping="/css/**" location="/templates/"/>
に
<mvc:resources mapping="/css/**" location="/css/"/>
を変更しても
<mvc:resources mapping="/css/**" location="/"/>
を試みたが、まだ結果を持っていません。
上のウェブサイトを参照する方法があるかどう
はまだ不思議だから、春のブートを使用していませんか? – chrylis
@chrylisはい、それはSpring-MVC + ThymeLeafです – utkillr