How to customize CSS using Spring MVC and Tiles

I am using Spring 3.0.5 and Tiles 2.2.2 and I am unable to get the stylesheet correctly specified in my application.

My stylesheet is in:

WEB-INF / Static / CSS / styles.css

How can I declare it correctly in my main JSP Tiles? I tried to figure this out for a couple of days, and I tried a number of suggestions that I saw here and on other sites. I tried adding

<mvc:resources ...> 

into my Spring configuration, although not all suggested solutions include this. Without a doubt, this is very simple, but I just did not find something that works.

Any help is much appreciated!

+4
source share
1 answer

Hi Jazz I used to host css files outside of web-inf with the following configuration using spring mvc and some jstl, but this configuration, in my opinion, is general, so I hope this "should help you":

In web.xml add:

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

And in the page title, I link to the css file with the following code:

 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <head> <title></title> <link href="${pageContext.request.contextPath}/css/global.css" rel="stylesheet" type="text/css" /> </head> 

Yours faithfully..

+6
source

All Articles