0

Am currently working on a spring mvc project on Eclipse. Am unable to get an external css working in a .jsp . My folder structure is as follows

Myproj, WebContent, WEB-INF, css, .css files

I use the following piece of code to reference the css file.

<link href="<c:url value="/css/filename.css" />" rel="stylesheet" type="text/css" />

I use spring jars version 3.1.0. I have also added the following lines of code within myproj-servlet.xml

    <mvc:annotation-driven /> 
<mvc:resources location="../css/" mapping="/css/**"/> 

Still am unable to access my css file or get it apply to my jsp file. While using firebug i see that the css link gets a 404 not found only. Where could be the issue/ how can i resolve?

1 Answer 1

1

Change your resource location to

<mvc:resources location="/WEB-INF/css/" mapping="/css/**"/> 

and while accessing on jsp you could very well write

<c:set var="context" value="${pageContext.request.contextPath}" />

<link rel="stylesheet" type="text/css" href="${context}/css/style.css" />

Cheers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.