Friday, 15 April 2011

spring - Unable to load resource using Thymeleaf View Layer -



spring - Unable to load resource using Thymeleaf View Layer -

i using thymeleaf view layer first time. have changed default location of templates web-inf/views , static resources sit down under /resources/css/ directory mapped /css/** pattern using spring resource handler. have page create utilize of css files fails during runtime. below exception. if remove <link> tags page loads without css applied. below link have in page

any pointers much appreciated.

<link rel="stylesheet" href="/resources/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}">

resource handlers:

@override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/css/**").addresourcelocations("/resources/css/"); registry.addresourcehandler("/js/**").addresourcelocations("/resources/js/"); }

exception:

javax.servlet.servletexception: filter execution threw exception org.springframework.boot.context.web.errorpagefilter.handleexception(errorpagefilter.java:135) org.springframework.boot.context.web.errorpagefilter.dofilter(errorpagefilter.java:104) org.springframework.boot.context.web.errorpagefilter.dofilter(errorpagefilter.java:85) org.springframework.boot.context.web.errorpagefilter.handleexception(errorpagefilter.java:135) org.springframework.boot.context.web.errorpagefilter.dofilter(errorpagefilter.java:104) org.springframework.boot.context.web.errorpagefilter.dofilter(errorpagefilter.java:85) org.springframework.boot.context.web.errorpagefilter.handleexception(errorpagefilter.java:135)

you using spring boot, don't need override addresourcehandlers(..), set resources in src/main/resources/static or src/main/resources/public or src/main/resources/resources, these folders registered default in spring boot.

update: set on /web-inf/static or web-inf/resources or web-inf/public

spring spring-mvc spring-security thymeleaf

No comments:

Post a Comment