将CSS文件链接到JSP [英] Linking CSS File To JSP
问题描述
我在我的WEB-INF文件夹中有一个css文件,在一个jsp页面中我给出了css文件的位置:
I have a css file in my WEB-INF folder and in a jsp page i have given the location of the css file as :
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/WEB-INF/Tabs.css"
但问题是它不与css文件链接。如果我从WEB-INF中取出css文件,它会工作得很好。
But the problem is it doesn't link with the css file. If i take out the css file from the WEB-INF, it works perfectly.
这是我第一次使用css。
This is my first time working with css.
这里有什么问题?
感谢您的时间。
推荐答案
这里的问题就像你描述的那样,css文件的位置。
位于WEB-INF文件夹中的所有资源都不能直接从Web浏览器访问,但必须通过servlet访问。
The problem here is just as you describe it, the location of the css-file. All resources located within the WEB-INF-folder is not reachable directly from the web browser, but has to be accessed through a servlet.
尝试将它们放在一个更常用的结构,如/ webapp / resources / css /Tabs.css并将href更改为$ {pageContext.request.contextPath} /webapp/resources/css/Tabs.css
Try instead to put them in a more common structure such as /webapp/resources/css/Tabs.css and change the href to "${pageContext.request.contextPath}/webapp/resources/css/Tabs.css"
* 编辑*
*Edit *
我称为webapp的文件夹可能有任何名称,但它的位置将是WEB-INF文件夹的父文件夹。
The folder I refer to as webapp might have any name, but the location of it would be the the parent folder of the WEB-INF folder.
这篇关于将CSS文件链接到JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!