zoukankan      html  css  js  c++  java
  • URL 参数为sql 有空格 的解决办法

    			var strsql=" select e.* from es_doc_main e where 1=1"
      				+" and e.doccode='"+prtNo+"' and e.subtype <> '1022' and e.busstype='TB' order by subtype ";
    			//strsql.replace(/s+/g,"%20");
      	      	if(arrResult[0][0]=='01')
      	      	{
      	      	easyScanWin = window.open( "./ProposalEasyScan.jsp?LoadFlag=5&QueryType=4&prtNo="+prtNo+"&MissionID="+tMissionID
                      +"&SubMissionID="+tSubMissionID+"&ProposalType=01" + "&ManageCom="+tManageCom+"&SqlStr="+encodeURI(strsql), "", ""); }

      这里 会显示无法找到页面404

    开发web服务中,发现当url中含有空格时,会报 400 error: bad request sytanx,经分析,url中含有特殊字符时,服务端可能无法识别。

    如+,空格,/,?,%,#,&,=等。该如何破呢?

    应当使用字符转义,将特殊字符进行编码表示。编码格式是:% + 对应字符的ascii码。

    +    URL 中+号表示空格                                 %2B   
    空格 URL中的空格可以用+号或者编码           %20 
    /   分隔目录和子目录                                     %2F     
    ?    分隔实际的URL和参数                             %3F     
    %    指定特殊字符                                          %25     
    #    表示书签                                                  %23     
    &    URL 中指定的参数间的分隔符                  %26     
    =    URL 中指定参数的值                                %3D

    所以需要处理(sql)中的空格,在js中处理办法

    ..."&ManageCom="+tManageCom+"&SqlStr="+encodeURI(strsql)
    

     在JSP中的处理办法

    <frame id="fraPic" name="fraPic" scrolling="auto"  src="../common/EasyScanQuery/EasyScanQuery.jsp?prtNo=<%=request.getParameter("prtNo")%>
    &QueryType=<%=request.getParameter("QueryType")%>&SqlStr=<%=java.net.URLEncoder.encode(request.getParameter("SqlStr"))%>">

    另外查看定义

     

    atzhang

  • 相关阅读:
    对于java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I错误解决
    attempted to assign id from null one-to-one
    The class has no identifier property
    javax.servlet.ServletException: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z
    final和static
    hibernate事务
    log4j:WARN Please initialize the log4j system properly.解决
    用最有效率的方法算出2乘以8等於几
    char型变量中能存贮一个中文汉字
    基本数据类型范围
  • 原文地址:https://www.cnblogs.com/zytcomeon/p/13344411.html
Copyright © 2011-2022 走看看