If the passed parameter is:
The code copy is as follows:
<a href="${pageContext.request.contextPath}/productdisplay/productDisplay_productDisplayUI.action?pkId=${pkId}&name=${ name}" style="color:white; margin-top:10px; margin-bottom: 10px;">${name}</a>
The js that get the url parameter are as follows:
The code copy is as follows:
/** Initialization loading ends*/
function getUrlVars(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?')+1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
If there is Chinese in the url, there will be Chinese garbled when taking parameters. You must use the decodeURI() method to decode it as follows:
The code copy is as follows:
//Get the pkId of the category
var params = getUrlVars();
//Get the id of the classification in this
var parentId = params[params[0]];
//Get the name of the category
var productName = decodeURI(params[params[1]]);