在jsp頁面如何獲得url引數

2022-09-28 19:36:24 字數 616 閱讀 7306

當乙個url過來時,如:http://localhost:8080/pro/dem程式設計客棧o/hello.jsp?name=john,在hello.jsp頁面,我們可以這樣得到程式設計客棧name的值:

複製** **如下:

string p程式設計客棧ath程式設計客棧 = request.getcontextpath();

string basepath = request.getscheme()+程式設計客棧"://"+request.getservername()+":"+request.getserverport()+path+"/";

string name = request.getparameter("name");//用request得到

%>

然後在hello:中顯示。

也可以在body中直接用${}得到,因為當使用jstl時,url請求引數被放置到隱含物件param中。所以可以這樣寫:

複製** **如下:

hello:$

依據此邏輯,在使用jquery時,也可以用同樣的方法得到,如:

$(function());

});

本文標題: 在jsp頁面如何獲得url引數

本文位址:

在jsp頁面如何獲得url引數

當乙個url過來時,如 http localhost 8080 pro demo hello.jsp?name john,在hello.jsp頁面,我們可以這樣得到name的值 string path request.getcontextpath string basepath request.ge...

在jsp頁面如何獲得url引數

方法一 當乙個url過來時,如 http localhost 8080 pro demo hello.jsp?name john,在hello.jsp頁面,我們可以這樣得到name的值 string path request.getcontextpath string basepath reques...

在頁面獲取在url後面的引數

跳轉到login.jsp頁面的鏈結 var url window.location.href 獲取當前頁面的鏈結 window.location.href login.jsp?url encodeuricomponent url 傳遞的時候,帶位址傳遞過去 在login.jsp頁面 把uri獲取到,...