href="${ctx}/goPageCenter?code=promos">优惠活动</a> ${ctx}这个啥意思,$符号啥意思?
光阴似箭催人老,日月如移越少年。
ctx是一個變量,${}包含住它,就是取得它的值。比如,有一個map。 它的結構是key,value。 map.put("ctx",www.baidu.com);那麼${ctx}拿到的就是www.baidu.com
取得域中指定名稱的值
簡單來說就是待取值的「?」
取得變數ctx的值
在jsp中的網域中取得值,1 page目前頁,透過在目前頁設定值取得,,${pageScope.ctx}值為"http://localhost:8080/"; <c:set var="ctx" value="http:// localhost:8080/">,${pageScope.ctx}值为"http://localhost:8080/"; 2 request.setAttribute("ctx", "http://localhost:8080/"), ${requestScope.ctx}值为"http://localhost:8080/";3 request.getSession().setAttribute("ctx", "http://localhost:8080/"), ${sessionScope.ctx}值为"http://localhost:8080/"; 4 request.getSession().getServeltContext().setAttribute("ctx", "http://localhost:8080/")2 request.setAttribute("ctx", "http://localhost:8080/"), ${requestScope.ctx}值為"http://localhost:8080/";
,${pageScope.ctx}值為"http://localhost:8080/"; <c:set var="ctx" value="http:// localhost:8080/">,${pageScope.ctx}值为"http://localhost:8080/"; 2 request.setAttribute("ctx", "http://localhost:8080/"), ${requestScope.ctx}值为"http://localhost:8080/";3 request.getSession().setAttribute("ctx", "http://localhost:8080/"), ${sessionScope.ctx}值为"http://localhost:8080/"; 4 request.getSession().getServeltContext().setAttribute("ctx", "http://localhost:8080/")2 request.setAttribute("ctx", "http://localhost:8080/"), ${requestScope.ctx}值為"http://localhost:8080/";
<c:set var="ctx" value="http:// localhost:8080/">
request.setAttribute("ctx", "http://localhost:8080/")
request.getSession().setAttribute("ctx", "http://localhost:8080/")
request.getSession().getServeltContext().setAttribute("ctx", "http://localhost:8080/")
request.getSession().setAttribute("ctx", "http://localhost:8080/"), ${sessionScope.ctx}值為"http://localhost:8080/"; 4 request.getSession().getServeltContext().setAttribute("ctx", "http://localhost :8080/"), ${applicationScope.ctx}值為"http://localhost:8080/"; 🎜這是4個域page,request,session,application,如果只用${ctx},那麼就會從這四個域中找到該對象,如果沒有找到,那麼就會返回空值,不是null;除了第一個是在本頁面設置之外,其他的幾個都是在前幾個請求中設置,有興趣可以去百度這幾個域的範圍是怎麼樣的🎜
4 request.getSession().getServeltContext().setAttribute("ctx", "http://localhost :8080/"), ${applicationScope.ctx}值為"http://localhost:8080/";
request.getSession().getServeltContext().setAttribute("ctx", "http://localhost :8080/")
${} 這種寫法叫el表達式, 在jsp中,是在以此在page,request,session,application從查找鍵值對的值,直到找到為止.你jsp頁面裡面正常都是有一個ctx設定,正常IDE使用JSP範本產生的程式碼中也會自動產生這個設定的程式碼.他是來自於全域上下文的資料--專案請求的網域名稱位址
取得model中的值,ctx可以看做一個map的key。
ctx
ctx是一個變量,${}包含住它,就是取得它的值。比如,有一個map。
它的結構是key,value。 map.put("ctx",www.baidu.com);
那麼${ctx}拿到的就是www.baidu.com
取得域中指定名稱的值
簡單來說就是待取值的「?」
取得變數ctx的值
在jsp中的網域中取得值,,${pageScope.ctx}值為"http://localhost:8080/";
31 page目前頁,透過在目前頁設定值取得,
<c:set var="ctx" value="http:// localhost:8080/">
,${pageScope.ctx}值为"http://localhost:8080/";2
request.setAttribute("ctx", "http://localhost:8080/")
, ${requestScope.ctx}值为"http://localhost:8080/";3
request.getSession().setAttribute("ctx", "http://localhost:8080/")
, ${sessionScope.ctx}值为"http://localhost:8080/";4
request.getSession().getServeltContext().setAttribute("ctx", "http://localhost:8080/")
2request.setAttribute("ctx", "http://localhost:8080/")
, ${requestScope.ctx}值為"http://localhost:8080/";request.getSession().setAttribute("ctx", "http://localhost:8080/"), ${sessionScope.ctx}值為"http://localhost:8080/";
4
🎜這是4個域page,request,session,application,如果只用${ctx},那麼就會從這四個域中找到該對象,如果沒有找到,那麼就會返回空值,不是null;除了第一個是在本頁面設置之外,其他的幾個都是在前幾個請求中設置,有興趣可以去百度這幾個域的範圍是怎麼樣的🎜request.getSession().getServeltContext().setAttribute("ctx", "http://localhost :8080/")
, ${applicationScope.ctx}值為"http://localhost:8080/";${} 這種寫法叫el表達式, 在jsp中,是在以此在page,request,session,application從查找鍵值對的值,直到找到為止.
你jsp頁面裡面正常都是有一個ctx設定,正常IDE使用JSP範本產生的程式碼中也會自動產生這個設定的程式碼.他是來自於全域上下文的資料--專案請求的網域名稱位址
取得model中的值,
ctx
可以看做一個map的key。