关于${ctx}拿不到值的问题

当项目开发时我们喜欢用
<c:set var="ctx" value="${pageContext.request.contextPath}"/>来获取项目根目录,但是当项目如果为ROOT下时,是获取的空值。这是有另一个方法可以实现。
<base href="http://...">来设置根目录访问地址。

关于base标签的知识补充

基连接 :设置基础路径的

如果你的<head></head>部分定义了:<base href="http://www.google.com/">,那么以后你就不用每次都把路径全部写上了

例如:


以前:<a href="http://www.google.com/xxx.html"></a>,

现在:<a href="xxx.html"></a> //<head></head>部分加了:<base href="http://www.google.com/">后


以前:<img src="http://www.google.com/xxx.jpg">

现在:<img src="xxx.jpg"> //<head></head>部分加了:<base href="http://www.google.com/">后


以前:<form action="http://www.google.com/xxx.html">

现在:<form action="xxx.html"> //<head></head>部分加了:<base href="http://www.google.com/">后


以前:<iframe src="http://www.google.com/xxx.html">

现在:<iframe  src="xxx.html"> //<head></head>部分加了:<base href="http://www.google.com/">后



原文地址:https://www.cnblogs.com/jpfss/p/9116152.html