zoukankan      html  css  js  c++  java
  • 课时4:l两种取值符号以及ParameterType为简单,对象,嵌套对象类型

    .1)输入参数:ParameterType

      1.类型为简单类型(8个基本类型+String)

        1.1${} 和 #{}的区别   

          (1)#{任意值}

           ${value},其中的占位符只能是value

          (2)#{}自动给String类加上‘ ’ (自动类型转换)

            ${}原样输出,但是适用于 动态排序( 动态字段)  

            动态排序的实例:

    <!--    动态排序-->
        <select id="selectStudentByOrderBy" parameterType="string" resultType="student">
            select * from student order by ${value} desc
        </select>

            如果使用#{}会自动的添加‘ ‘号 就不符合数据库的语句

           (3) #{}可以防止sql注入

             ${}不防止

      2.类型是对象或者是嵌套对象类型

        2.1 对象类型

    <!--    通过家庭地址或者学校地址插叙学生-->
        <select id="selectStudentByhomeOrSchool" parameterType="Address" resultType="student">
    select stuno,stuName from student where homeaddress=#{homeAddress} or schooladdress='${schoolAddress}'
        </select>

           2.2 嵌套对象类型

     <!--    通过家庭地址或者学校地址插叙学生-->
        <select id="selectStudentByhomeOrSchool" parameterType="student" resultType="student">
    select stuno,stuName from student where homeaddress=#{address.homeAddress} or schooladdress='${address.schoolAddress}'
        </select>

       2.2.1 #{}${}两个都支持级联 有点像EL表达式

      

     

  • 相关阅读:
    Codeforces 1255B Fridge Lockers
    Codeforces 1255A Changing Volume
    Codeforces 1255A Changing Volume
    leetcode 112. 路径总和
    leetcode 129. 求根到叶子节点数字之和
    leetcode 404. 左叶子之和
    leetcode 104. 二叉树的最大深度
    leetcode 235. 二叉搜索树的最近公共祖先
    450. Delete Node in a BST
    树的c++实现--建立一棵树
  • 原文地址:https://www.cnblogs.com/thisHBZ/p/12455110.html
Copyright © 2011-2022 走看看