Use url to pass multiple parameters

When I first started to contact jsp, I prefer to use the onclick method of the button tag to jump the page. But the various problems about page jumping are really crowded. The following records are just for myself to check later.

What to do when Qone encounters Chinese when using url to pass parameters

    Encoding and decoding: encode with encodeURI during transmission, and decode with URLEncoder.encode when obtaining parameters;

    Page 1:

          

function sub(){
     
     var content1 = document.getElementById("tn");
     var content2 = document.getElementById("ln");
     alert(content1.value);
     alert(content2.value);
   
     window.location.href="value.jsp?"+"tn="+encodeURI(content1.value)+"&ln="+encodeURI(content2.value);

  
 }

 

Page 2:

When defining the get method, decode

public String get_url_Name() throws UnsupportedEncodingException {
        String encodedname = URLEncoder.encode(name, "UTF-8");
        return encodedname;
    }

Qtwo: How to write when url transmits multiple parameters

href="Next page.jsp?"+parameter+"¶meter name"+parameter value

The plus sign cannot be less, otherwise the page jump will fail

ps: This method of clearing the address is not safe, but there is no other method for the time being. I will use it and I will look back when I have time.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325862389&siteId=291194637