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表达式

      

     

  • 相关阅读:
    js 跳转链接
    reg.test is not a function 报错
    html中button自动提交表单?
    mysql主从复制及双主复制
    nginx反向代理后端web服务器记录客户端ip地址
    mysql多实例-主从复制安装
    LVS+Keepalived高可用负载均衡集群架构实验-01
    debug调试
    常用网站总结
    项目部署
  • 原文地址:https://www.cnblogs.com/thisHBZ/p/12455110.html
Copyright © 2011-2022 走看看