Java parses the value passed by the front end, the type is name=1111&username=22

protected String getParam(String str,String key)
{
    
    
String rtn = null;
String arr [] = str.split("&");
for(String s : arr)
{
    
    
String key0 = s.split("=")[0];
String value = s.split("=")[1];
if(key0.equals(key))
{
    
    
rtn = value;
break;
}
}
return rtn;
}
//调用
String str = "a=1111&d=22";
getParam(str,"a"); 

Guess you like

Origin blog.csdn.net/qq_41353397/article/details/113447716