HTML中接收URL引數的三種方式

2021-06-22 14:28:48 字數 637 閱讀 2514

1.使用 window.location.search 來取得後面的引數

// param引數的名

function getparameter(param)

然後呼叫getparameter 方法: var temp = getparameter("aa");

2.使用 window.location.href 來取得後面的引數

var url=window.location .href;

var aa=url.indexof(''='');

if (aa == -1)

return "";

url=url.substring(aa+1);

window.alert(url);

3。將以下**另存為html檔案:aa.htm,然後開啟站點:

回車即可顯示演示效果,正常接收由html檔案傳遞的值.

接收前端請求引數的三種方式

這種方式可以自動對映 public string test1 string name,model model 這種情況需要通過 requestparam設定引數名對映,建議採用這種方式,更加清晰直觀知道是接受的前端引數 public string test2 requestparam usernam...

用struts2接收三種引數

yangguang huoyunshenstruts2中action接收引數的方法主要有以下三種 struts2中action接收引數的方法主要有以下三種 1.使用action的屬性接收引數 a.定義 在action類中定義屬性,建立get和set方法 b.接收 通過屬性接收引數,如 usernam...

struts2 action接收引數的三種方法

action接收引數的三種方法 1.使用action的屬性接收引數 a.定義 在action類中定義屬性,建立get和set方法 b.接收 通過屬性接收引數,如 username c.傳送 使用屬性名傳遞引數,如 user1 add?name magci age 18 eg public class...