精华内容
下载资源
问答
  • forEach报错

    2019-01-08 09:10:43
    问题描述: forEach报错undefined 原因: 空数组用forEach会报错 解决方案: 给数组赋值,检查数组

    问题描述:

    forEach报错undefined

    原因:

    空数组用forEach会报错

    解决方案:

    给数组赋值,检查数组

    展开全文
  • 主要给大家介绍了mybatis中foreach报错:_frch_item_0 not found的解决方法,文章通过示例代码介绍了详细的解决方法,对大家具有一定的参考学习价值,需要的朋友们下面来一起看看吧。
  • 今天我写php对某个表进行插入,image.png之前gff_line我给它取名为 index,导致我一直产生mysql语法报错$EXM9U%ZFZHR4XUI}}XFX4Y.png他说明在index附近有报错,我后来才意识到index可能是mysql的标识符,在php5.5.12...

    今天我写php对某个表进行插入,

    a7023572c9cd

    image.png

    之前gff_line我给它取名为 index,导致我一直产生mysql语法报错

    a7023572c9cd

    $EXM9U%ZFZHR4XUI}}XFX4Y.png

    他说明在index附近有报错,我后来才意识到index可能是mysql的标识符,在php5.5.12中不能采用index作为字段名称。

    因此我把index改成另外一个名字,我的文件就能跑通了。

    顺便附上我的code

    function read_all_dir ( $dir )//read all the file from dir

    {

    $result = array();

    $handle = opendir($dir);

    if ( $handle )

    {

    while ( ( $file = readdir ( $handle ) ) !== false )

    {

    if ( $file != '.' && $file != '..')

    {

    $cur_path = $dir . DIRECTORY_SEPARATOR . $file;

    if ( is_dir ( $cur_path ) )

    {

    $result['dir'][$cur_path] = read_all_dir ( $cur_path );

    }

    else

    {

    $result['file'][] = $cur_path;

    }

    }

    }

    closedir($handle);

    }

    return $result;

    }

    error_reporting(E_ALL &~E_NOTICE &~E_DEPRECATED);//report the mysql error

    $connect = mysqli_connect('localhost','root','','dbcan3') or die('Unale to connect');

    $hostdir = "D:/project/gff/cgc_table";//read all the cgc data, the data file is named by genome

    $dir = read_all_dir($hostdir);

    //print_r($dir);

    $i = 0;

    foreach ($dir['file'] as $key => $value) {

    $fp = fopen($value,"r");

    $str ="";

    while(!feof($fp)){

    $i = $i + 1;

    $str = fgets($fp);

    $str = trim($str);

    if(strcmp($str[0],"+")!=0){//extract the non "+++" line

    $arr = explode("\t",$str);

    $sql_insert = "INSERT INTO cgc_new_table(gff_line,

    type,prev_dis,for_dis,cgc_no,refseq_id,start,end,pro,strand,product,signature,gen,taxid,sp_name)

    VALUES ('"

    .mysqli_escape_string($connect,$arr[0])."','"

    .mysqli_escape_string($connect,$arr[1])."','"

    .mysqli_escape_string($connect,$arr[2])."','"

    .mysqli_escape_string($connect,$arr[3])."','"

    .mysqli_escape_string($connect,$arr[4])."','"

    .mysqli_escape_string($connect,$arr[5])."','"

    .mysqli_escape_string($connect,$arr[6])."','"

    .mysqli_escape_string($connect,$arr[7])."','"

    .mysqli_escape_string($connect,$arr[8])."','"

    .mysqli_escape_string($connect,$arr[9])."','"

    .mysqli_escape_string($connect,$arr[10])."','"

    .mysqli_escape_string($connect,$arr[11])."','"

    .mysqli_escape_string($connect,$arr[12])."','"

    .mysqli_escape_string($connect,$arr[13])."','"

    .mysqli_escape_string($connect,$arr[14])."');";

    $result_in = mysqli_query($connect, $sql_insert) or die ('Error querying database.'. mysqli_error($connect));

    if($i % 10000 == 0)

    print $i."\n";

    }

    }

    }

    //$result = mysqli_query($connect, $sql) or die ('Error querying database.'. mysqli_error($connect));

    ?>

    展开全文
  • JSP标签c:forEach报错(一)

    千次阅读 2014-03-31 21:41:02
    1、jsp标签c:forEach报错,具体错误如下: 三月 31, 2014 9:31:14 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [jsp] in context with path [/HighCharts] ...

    1、jsp标签c:forEach报错,具体错误如下:

    三月 31, 2014 9:31:14 下午 org.apache.catalina.core.StandardWrapperValve invoke
    严重: Servlet.service() for servlet [jsp] in context with path [/HighCharts] threw exception [Unable to compile class for JSP: 
    
    An error occurred at line: 17 in the jsp file: /JSP/forEach.jsp
    Syntax error on token ""O"", delete this token
    14:    <hr>
    15:    <%
    16: 			String[] array = { "A", "B", "C", "D", "E", "F","G","H","I","J","K","L","M","N"
    17: 		   					   "O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    18: 			request.setAttribute("array", array);
    19: 	%>
    20: 	<c:forEach items="${array}" var="arr">
    
    
    Stacktrace:] with root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP: 
    
    An error occurred at line: 17 in the jsp file: /JSP/forEach.jsp
    Syntax error on token ""O"", delete this token
    14:    <hr>
    15:    <%
    16: 			String[] array = { "A", "B", "C", "D", "E", "F","G","H","I","J","K","L","M","N"
    17: 		   					   "O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    18: 			request.setAttribute("array", array);
    19: 	%>
    20: 	<c:forEach items="${array}" var="arr">
    
    
    Stacktrace:
    	at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    	at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
    	at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
    	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    	at java.lang.Thread.run(Thread.java:722)

    2、错误原因

         由于在数组中缺少逗号,导致错误发生

    String[] array = { "A", "B", "C", "D", "E", "F","G","H","I","J","K","L","M","N"
    		   					   "O","P","Q","R","S","T","U","V","W","X","Y","Z"};


    3、解决办法
         在“N”后加上逗号

    展开全文
  • Mybatis使用foreach报错: org.apache.ibatis.binding.BindingException: Parameter 'busiOrderNoList' not found. Available parameters are [collection, list] mapper.java类如下 public List<...

    Mybatis使用foreach报错:

    org.apache.ibatis.binding.BindingException: Parameter 'busiOrderNoList' not found. Available parameters are [collection, list]

     mapper.java类如下

    public List<PayrollTradenoPay2CDTO> findTradeInfoForBusiOrderId(List<String> busiOrderNoList);

    mapper.xml如下:使用了foreach

           <if test="busiOrderNoList!=null ">
                and pt.busi_order_no in
                <foreach item="item" index="index" collection="busiOrderNoList" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

    这里报错是找不到参数"busiOrderNoList",看来mapper.java的参数并没传进来.

    默认情况下(没有指定parameterType时),Mybatis把参数按顺序转化为#{0},#{1}或者#{param0}#{param1}有以下三种情况

    (1)当只有一个参数时,并且没有参数中没有if判断时,可以指定参数#{aaa}或者#{0}或者随便#{xxxx}都可以获取值.

    (2)当有两个以上参数时,并且没有参数中没有if判断时.指定参数名#{aaa}#{bbb}或者#{0}#{1}获取不到值,报错

    Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2],按照提示替换为#{arg0}#{arg1}或者#{param0}#{param1}就可以了.

    (3)当有if时,只能用默认的参数名#{arg0}#{arg1}或者#{param0}#{param1}.如果不想用默认的,只能加@Param指定参数名.

    当前问题有两种解决方式:

    1.按照报错提示,将xml里的参数busiOrderNoList改为list或者collection

    <if test="list!=null ">
                and pt.busi_order_no in
                <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
                    #{item}
                </foreach>
    </if>

    2. 在mapper.java中添加@Param("busiOrderNoList")注解.如下..

    public List<PayrollTradenoPay2CDTO> findTradeInfoForBusiOrderId(@Param("busiOrderNoList") List<String> busiOrderNoList);

    Mybatis的参数绑定用法有好几种.下面介绍常用的3种.

    1. 使用对象传递参数.适用于参数比较多.xml需要指定parameterType

      //mapper.java
      
      List<BizProcessDataEntity> findFinishTaskList(ProcessTaskQueryParam processTaskQueryParam);
      
      //mapper.xml 此时需要指定参数类型.比如(parameterType="com.ali.dto.param.ProcessTaskQueryParam" )
      #{map里的key}


       

    2. 使用@Param传递参数.适用于单个参数,或者少数几个参数.不必指定parameterType

    public List<PayrollTradenoPay2CDTO> findTradeInfoForBusiOrderId(@Param("busiOrderNoList") List<String> busiOrderNoList);

     这里有个注意点.@Param相当于给参数指定了参数名.所以xml里面必须使用指定的名字,按名字匹配参数.和其它两种不一样,可以不必指定parameterType

    3.使用map传递参数.比如 Map<String, Object> queryMap,map的value可以是任何类型.比如List.xml需要指定parameterType

    //mapper.java
    List<BizProcessDataEntity> findDistinctNameList(Map map);
    
    //mapper.xml 此时需要指定参数类型为map.(parameterType="java.util.Map")
    #{map里的key}

     


    ----------------------------------------------如有疑问,欢迎留言.------------------------------------------------


     

    展开全文
  • mybatis 使用foreach 报错

    2019-10-23 09:32:03
    mybatis 使用<foreach 一直报There is no getter for property named, <if test="statusList != null and statusList != ''"> AND a.status in ...
  • Array.from($(".content-input")).forEach(e => { // 空值 if (!$(e).val()) { $(e).focus(); alert("请输入完整的模板数据..."); throw new Error("NO_DATA"); } }); } catch (error) { if (error....
  • 我正在尝试遍历所有getElementsByTagName(“input”)使用forEach 重构的元素。有什么想法为什么在FF,Chrome或IE中不起作用? 解决: 您需要使用以下命令将节点列表转换为数组: ....
  • 问题情境:thinkphp3.2版本,使用四层<...循环变量时,报错以下错误: syntax error, unexpected 'endforeach' (T_ENDFOREACH), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) 解决...
  • Foreach报错,index失效

    2019-02-15 20:14:43
    报错“”:  org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_item_0' in 'class com.bls.entity.Page'   异常代码:  &lt;if test=" CLASS_IDS...
  • 或许是惯性思维,在mybatis使用foreach循环调用的时候,很多时候都是传一个对象,传一个List的情况很少,所以写代码有时候会不注意就用...mybatis foreach报错It was either not specified and/or could not be f...
  • vue 使用forEach报错,this指向问题

    千次阅读 2019-04-15 10:26:23
    getCrumbs(){ let crumbs = JSON.parse(localStorage.getItem( "crumbs" ));... //[Vue warn]: Error in created hook: "TypeError: Cannot set property 'manageClass' of undefined" 报错 crumbs.forEach...
  • foreach报错:syntax error at or near " 

    千次阅读 2019-06-19 14:06:07
    特别注意:说明图中红圈处包含了一个特殊字符,不是空格字符,查询的时候就报错了。 select count(guid) from class where id in <foreach collection="GuidList" index="index" item="item" open="(" close=...
  • 找了半天,在Intel github 的提问处找到了和我一样的问题,还有解决方案 ...foreach并不属于C++标准语法,QT和realsense分别定义了foreach,导致冲突。 解决: 找到 rs_frame.hpp 将里面所有的 “...
  • 同标题,????找了好久的原因,没想到是因为大小写。。。
  • .2,jdk版本也高于1.5(见下图),但是报错:Syntax error, 'for each' statements are only available if source level is 1.5 or greater?请各位大神知道是什么原因吗(怎样解决)[img=...
  • int deleteUsers(List<Long> list);
  • JSP标签c:forEach报错(二)

    千次阅读 2014-03-31 21:48:54
    An error occurred at line: 25 in the jsp file: /JSP/forEach.jsp List cannot be resolved to a type 22: 23: </c:forEach> 24: 25: List<String> list = new ArrayList(); 26: list.add("You...
  • mybatis中foreach报错_frch_item_0 not found

    千次阅读 2016-12-25 22:32:00
    _frch_item_0 not found There is no getter for property named 'states' in 'class com.xingguo.model.User' mybatis动态sqlforeach
  • 今天发现了一个折磨我一天的问题: 在jsp文件中使用 <c:forEach items="${checkResult}" var="item">...一直报错: [ERROR] 2013-12-09 15:03:20,740 method:org.apache.catalina.core.StandardWrappe...
  • 后台封装的数据是个list,传递给前台,显示如下: 1 <c:forEach items="${userInfo}" var="user"> 2 用户Name: ${user.myUserName} <br/> 3 用户Id: ${user.myUserId} <br/>...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 74,023
精华内容 29,609
关键字:

foreach报错