1

Why we need absolute path and how I can set absolute path for css files which are included in my project.I am using spring mvc.The css files are in different folder which is inside web-inf folder in tomcat/webapp.Now i am using something like below

<link href="AllCSS/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>

what should i need to do exactly?

5
  • When you say absolute path, what do you mean? And what folder are the CSS files in now? Commented Jan 6, 2015 at 10:47
  • @ZougenMoriver,i need something like this " test.co.uk/public " when I open view source ,it is possible to see the scripts being called from an external domain. Commented Jan 6, 2015 at 11:19
  • I'm not familiar with Spring MVC, but this answer might help you: stackoverflow.com/a/15718815/940252 Commented Jan 6, 2015 at 11:51
  • possible duplicate of Get Root/Base Url In Spring MVC Commented Jan 6, 2015 at 11:52
  • can any one tell me why we need to use absolute url Commented Jan 6, 2015 at 12:40

1 Answer 1

1

Absolute in a webapp assumes starting from the webapp root context, in your case if /Allcss is a directory under root, absolute would mean

<link href="${pageContext.request.contextPath}/Allcss/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>

if its a webapp context than

<link href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
Sign up to request clarification or add additional context in comments.

2 Comments

..thanks for help..But this doesnt contain the "http://" part..am getting only "project/Allcss/plugins/font-awesome/css/font-awesome.min.css" do we need http part realy to make url as absolute ?
when you're linking to your local resources it doesn't have to contain http explicitly, when starting the app the above will be equivalent to e.g. http:// localhost:8080/plugins/font-awesome/css/font-awesome.min.css. When you're reaching for an external resource than you'll need a full url. Also, for what concerns your question in the comment above if you linked your resources correctly it doesn't matter if you used absolute vs relative, jeffreybarke.net/2013/06/paths-and-urls-relative-and-absolute you should use what works for you better

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.