在eclipse动态web项目中,如何将css链接到webcontent文件夹中的jsp文件 [英] In eclipse dynamic web project, how to link css to jsp file in webcontent folder

查看:838
本文介绍了在eclipse动态web项目中,如何将css链接到webcontent文件夹中的jsp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中,我在WebContent文件夹下创建了一个动态Web项目和一个JSP文件。我还在WebContent文件夹下创建了一个CSS文件。然后我在JSP中使用< link rel =stylesheettype =text / csshref =XXX.css> 链接到CSS文件,当我在web服务器(Tomcat)上运行时CSS不适用。

In Eclipse, I created a Dynamic Web Project and a JSP file under WebContent folder. I also created a CSS file under the WebContent folder. Then I use <link rel="stylesheet" type="text/css" href="XXX.css"> in the JSP to link to the CSS file but when I run on web server (Tomcat) the CSS didn't apply. Can someone tell me why?

推荐答案

您必须将web项目名称放在css文件的地址路径之前

You must put your web project name before the address path of your css file

示例:

<link rel="stylesheet" href="/YourProjectName/XXX.css" type="text/css">

或更动态的方式:

<link rel="stylesheet" href="${pageContext.request.contextPath}/XXX.css" />

有乐趣:)

这篇关于在eclipse动态web项目中,如何将css链接到webcontent文件夹中的jsp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆