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?

user3132347
  • 363
  • 1
  • 7
  • 27

1 Answers1

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"/>
Master Slave
  • 27,771
  • 4
  • 57
  • 55
  • ..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 ? – user3132347 Jan 06 '15 at 12:43
  • 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, http://jeffreybarke.net/2013/06/paths-and-urls-relative-and-absolute/ you should use what works for you better – Master Slave Jan 06 '15 at 14:09