jsp中的绝对URL [英] Absolute url in jsp
本文介绍了jsp中的绝对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
虽然我的jsps中包含css,js和图像,但我仍然面临解析相对URL的问题.在刷新页面或单击后退"按钮时,URL会更改.我想解决该问题的一种方法是使用绝对URL包含外部文件.但是我找不到如何使用对相对URL的引用并使用它.有人可以帮我吗?
While including css, js and images in my jsps I am facing a problem resolving relative urls. The urls get changed on refreshing the page or clicking the back button. I suppose one solution to the problem would be to include external files by using absolute urls. But I can't find out how to use a reference to the relative url and use it. Can anyone please help me on this?
推荐答案
这是您要寻找的吗?
${pageContext.servletContext.contextPath}
,然后在您的jsp中:
and then in your jsp:
<link rel="stylesheet" href="${pageContext.servletContext.contextPath}/css/page.css" media="all" type="text/css" />
这篇关于jsp中的绝对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文