查询字符串在将其传递到 jsp 页面中的 href 时需要额外的字符
Query string takes extra character while passing it into the href in jsp page
我在 JSP 的 href 中的查询字符串中传递一个参数。所以当我点击 link 之后,它会提供一些额外的字符以及参数值。
String s="approved";
String activationcode=request.getParameter("activationcode");
if(activationcode!=null)
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","up78cp5317");
Statement stmt=con.createStatement();
stmt.execute("update (select Approval.status as st from Approval join Activity on Activity.userid=Approval.id where Activity.activationcode='"+activationcode+"') up set up.st='"+s+"'");
//stmt.executeUpdate("UPDATE ( SELECT Approval.STATUS AS st FROM Approval JOIN Activity ON Activity.userid = Approval.id WHERE Activity.activationcode = '"+activationcode+"') up SET up.st = '"+s+"'");
//stmt.executeUpdate("update (select Approval.status as st from Approval join Activity on Activity.userid=Approval.id where Activity.activationcode='"+activationcode+"') up set up.st='"+s+"'");
//stmt.executeUpdate("delete from activity where activationcode='"+activationcode+"'");
stmt.close();
con.close();
}
点击 link 后,我得到的是:
http://localhost:8090/TL/OnlineApprovalButton.jsp?activationcode=%2780f91f53-918f-45c4-9ee6-9eda9c40f72d%27
这里%27是在参数值的head和trail中加入
激活码的值可能以撇号 (') 开头,当您执行 url 撇号编码时,结果为 %27。您可以在此处找到不同字符的 url 编码。 https://www.w3schools.com/tags/ref_urlencode.asp
我只是替换字符串,然后 trim 字符串。
String activationcode=request.getParameter("activationcode").repalceAll("'"," ").trim();
我在 JSP 的 href 中的查询字符串中传递一个参数。所以当我点击 link 之后,它会提供一些额外的字符以及参数值。
String s="approved";
String activationcode=request.getParameter("activationcode");
if(activationcode!=null)
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","up78cp5317");
Statement stmt=con.createStatement();
stmt.execute("update (select Approval.status as st from Approval join Activity on Activity.userid=Approval.id where Activity.activationcode='"+activationcode+"') up set up.st='"+s+"'");
//stmt.executeUpdate("UPDATE ( SELECT Approval.STATUS AS st FROM Approval JOIN Activity ON Activity.userid = Approval.id WHERE Activity.activationcode = '"+activationcode+"') up SET up.st = '"+s+"'");
//stmt.executeUpdate("update (select Approval.status as st from Approval join Activity on Activity.userid=Approval.id where Activity.activationcode='"+activationcode+"') up set up.st='"+s+"'");
//stmt.executeUpdate("delete from activity where activationcode='"+activationcode+"'");
stmt.close();
con.close();
}
点击 link 后,我得到的是: http://localhost:8090/TL/OnlineApprovalButton.jsp?activationcode=%2780f91f53-918f-45c4-9ee6-9eda9c40f72d%27
这里%27是在参数值的head和trail中加入
激活码的值可能以撇号 (') 开头,当您执行 url 撇号编码时,结果为 %27。您可以在此处找到不同字符的 url 编码。 https://www.w3schools.com/tags/ref_urlencode.asp
我只是替换字符串,然后 trim 字符串。
String activationcode=request.getParameter("activationcode").repalceAll("'"," ").trim();