Home >Web Front-end >JS Tutorial >Transmitting and receiving values ​​​​of url in jsp

Transmitting and receiving values ​​​​of url in jsp

一个新手
一个新手Original
2017-09-08 09:06:371770browse

Transmitting and receiving values ​​of url in jsp

Jsp passing value:

    var myurl="index.jsp?id="+id+"&name="+name;
    window.location.assign(encodeURI(myurl));

jsp receiving value:

    var url=decodeURI(location.href);    
    var tmp1=url.split("?")[1]; 
    var tmp2=tmp1.split("&")[0]; 
    var tmp3=tmp2.split("=")[1]; //获取数据
    var tmp4=tmp1.split("&")[1]; 
    var tmp5=tmp4.split("=")[1]; //id
    var tmp6=tmp1.split("&")[2]; 
    var tmp7=tmp6.split("=")[1]; //name
      var moduleData = tmp3; 
      var id =tmp5; 
      var name = tmp7;

It can also solve the Chinese garbled code when url is passing value.

The above is the detailed content of Transmitting and receiving values ​​​​of url in jsp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn