当前位置: 首页 > news >正文

幼儿园网站建设总结怎样去推广自己的网店

幼儿园网站建设总结,怎样去推广自己的网店,全国旅游大型网站建设,wordpress 需要事务标签 if标签 当提交的表单中有些为非必填项&#xff0c;用户并没有上传这些属性的值&#xff0c;那么程序可以上传NUll&#xff0c;也可以用if标签判断用户有没有上传这个值 <if test"参数!null">操作 </if>其中test中填写一条语句&#xff0c;如果得…

标签

if标签

当提交的表单中有些为非必填项,用户并没有上传这些属性的值,那么程序可以上传NUll,也可以用if标签判断用户有没有上传这个值

<if test="参数!=null">操作
</if>

其中test中填写一条语句,如果得到true,就执行下面的操作,否则就不执行

例如,添加username,password和photo属性
UserMapper

int add2(UserInfo userInfo);

UserMapper.xml:
需要注意逗号的位置,如果photo未传输数值,那么形成的句子就是username,password,不会有语法问题

<insert id="add2">insert into userinfo(username,<if test="photo != null">photo,</if>password)values(#{username},<if test="photo != null">#{photo},</if>#{password})
</insert>

UserMapperTest:

@Test
void add2() {UserInfo userInfo = new UserInfo();userInfo.setUsername("zhangsan");userInfo.setPhoto(null);userInfo.setPassword("333");int result = userMapper.add2(userInfo);System.out.println(result);
}

可以看到,当photo并没有传值时,生成的JDBC语句中就没有photo
在这里插入图片描述

trim标签

如果所有的属性都是非必填项,那么逗号的位置就很难确定了,因此可以使用trim标签来拼接字符串

<trim prefix="前缀内容" suffix="后缀内容" prefixOverrides="去除前缀相关值" suffixOverrides="去除后缀相关值"></trim>
  • prefix会在最前面添加内容
  • suffix会在最后面添加内容
  • prefixOverrides则是如果最后一个字符是指定值,就去掉该值(例如prefixOverrides=“,”,那么如果最前面是逗号就会去除最前面的逗号)
  • suffixOverrides则是去除最后面的值
    一般来说,trim会搭配if标签来使用,例如下面这个场景:username,password,photo都是非必填项

UserMapper:

int add3(UserInfo userInfo);

UserMapper.xml
这里会自动添加(),并且如果最后是逗号,会删除这个逗号

<insert id="add3">insert into userinfo<trim prefix="(" suffix=")" suffixOverrides=","><if test="username != null">username,</if><if test="password != null">password,</if><if test="photo != null">photo,</if></trim>values<trim prefix="(" suffix=")" suffixOverrides=","><if test="username != null">#{username},</if><if test="password != null">#{password},</if><if test="photo != null">#{photo},</if></trim></insert>

UserMapperTest:

@Test
void add3() {UserInfo userInfo = new UserInfo();userInfo.setUsername("lisi");userInfo.setPhoto(null);userInfo.setPassword("444");int result = userMapper.add2(userInfo);System.out.println(result);
}

可以看到确实去除了password后面的逗号(也就是最后一个字符)
在这里插入图片描述

where标签

用来查找相关信息,会生成where的语句

  • where标签一般也是配合if来使用
  • where标签会自动帮助我们删除最前面的and关键字
  • where标签中如果没有内容,那么就不会产生where的关键字
    也就是说,下面这两种写法都是可以的,只不过where的写法更加简介
<select id="getListByParam" resultType="com.example.demo.entity.UserInfo">select * from userinfo<where><if test="username!=null">username = #{username}</if><if test="password!=null">and password = #{password}</if></where>
</select>
<select id="getListByParam" resultType="com.example.demo.entity.UserInfo">select * from userinfo<trim prefix="where" prefixOverrides="and"><if test="username!=null">username = #{username}</if><if test="password!=null">and password = #{password}</if></trim>
</select>

在这里插入图片描述

set标签

用来更改属性的值,会自动生成set语句

  • set标签一般配合if标签使用
  • set标签会自动去除最后一个逗号(英文)
<update id="update2">update userinfo<set><if test="username != null">username = #{username},</if><if test="password != null">password = #{password},</if><if test="photo != null">photo = #{photo}</if></set>where id = #{id}
</update>

也可以使用trim来完成这段代码
在这里插入图片描述

foreach标签

当我们需要大批量进行操作时,可以在代码中使用for循环,也可以直接在sql中进行批量操作,具体方法就是使用in()
语法格式:

<foreach collection="集合变量" open="前缀" close="后缀" item="集合中变量名" separator="分隔符">操作
</foreach>

例如,要删除大量指定id的用户信息:
UserMapper:

int deleteById(List<Integer> ids);

UserMapper.xml:

<delete id="deleteById">delete from userinfo where id in<foreach collection="ids" open="(" close=")" item="id" separator=",">#{id}</foreach>
</delete>

UserMapperTest:

@Test
void deleteById() {List<Integer> ids = new ArrayList<>();ids.add(1);ids.add(2);ids.add(3);int result = userMapper.deleteById(ids);System.out.println(result);
}

在这里插入图片描述


文章转载自:
http://metacenter.qpnb.cn
http://quickset.qpnb.cn
http://regret.qpnb.cn
http://accusatorial.qpnb.cn
http://endoplasm.qpnb.cn
http://exemplariness.qpnb.cn
http://climbable.qpnb.cn
http://spiritism.qpnb.cn
http://morocco.qpnb.cn
http://legendary.qpnb.cn
http://administrivia.qpnb.cn
http://covenantor.qpnb.cn
http://economization.qpnb.cn
http://falcate.qpnb.cn
http://washingtonian.qpnb.cn
http://philippopolis.qpnb.cn
http://culex.qpnb.cn
http://judoka.qpnb.cn
http://uba.qpnb.cn
http://ortanique.qpnb.cn
http://thoroughly.qpnb.cn
http://renegue.qpnb.cn
http://comble.qpnb.cn
http://infusorian.qpnb.cn
http://scarification.qpnb.cn
http://rove.qpnb.cn
http://gillyflower.qpnb.cn
http://deathtrap.qpnb.cn
http://disaster.qpnb.cn
http://retaliative.qpnb.cn
http://hellebore.qpnb.cn
http://ectoenzym.qpnb.cn
http://homoeopathist.qpnb.cn
http://unshakeable.qpnb.cn
http://warmth.qpnb.cn
http://propinquity.qpnb.cn
http://senatus.qpnb.cn
http://lapsible.qpnb.cn
http://cookware.qpnb.cn
http://crikey.qpnb.cn
http://undaunted.qpnb.cn
http://film.qpnb.cn
http://skiplane.qpnb.cn
http://awedness.qpnb.cn
http://resuscitative.qpnb.cn
http://immaculate.qpnb.cn
http://peeve.qpnb.cn
http://erysipelothrix.qpnb.cn
http://hafta.qpnb.cn
http://josephson.qpnb.cn
http://quatercentennial.qpnb.cn
http://stickybeak.qpnb.cn
http://boatmanship.qpnb.cn
http://coexist.qpnb.cn
http://airdent.qpnb.cn
http://hypsometrically.qpnb.cn
http://cariama.qpnb.cn
http://hypostasize.qpnb.cn
http://moonshiny.qpnb.cn
http://tinkal.qpnb.cn
http://sharefarmer.qpnb.cn
http://infringe.qpnb.cn
http://quernstone.qpnb.cn
http://lunarian.qpnb.cn
http://lienable.qpnb.cn
http://virbius.qpnb.cn
http://spoiler.qpnb.cn
http://tianjing.qpnb.cn
http://personally.qpnb.cn
http://atwitter.qpnb.cn
http://luge.qpnb.cn
http://pickwick.qpnb.cn
http://ichnolite.qpnb.cn
http://iniquitously.qpnb.cn
http://sprightful.qpnb.cn
http://huskiness.qpnb.cn
http://carragheenin.qpnb.cn
http://leery.qpnb.cn
http://shirttail.qpnb.cn
http://triangle.qpnb.cn
http://athymic.qpnb.cn
http://aphasiac.qpnb.cn
http://transit.qpnb.cn
http://bloomsburian.qpnb.cn
http://dictatress.qpnb.cn
http://diction.qpnb.cn
http://antenumber.qpnb.cn
http://cordillera.qpnb.cn
http://neckbreaking.qpnb.cn
http://pontus.qpnb.cn
http://piazza.qpnb.cn
http://precompiler.qpnb.cn
http://befoul.qpnb.cn
http://alated.qpnb.cn
http://hatching.qpnb.cn
http://tanrec.qpnb.cn
http://semibarbarous.qpnb.cn
http://ciseleur.qpnb.cn
http://isis.qpnb.cn
http://wantage.qpnb.cn
http://www.hrbkazy.com/news/81066.html

相关文章:

  • 首都城市环境建设委员会网站怎么做电商新手入门
  • 宝鸡网站建设公司资费惠州seo排名公司
  • 网站没有收录怎么办疫情最新政策最新消息
  • 动态网站用什么语言做唐山seo推广公司
  • 东营市建设信息网站什么是网络推广工作
  • 免费建站网站一级大录像不卡在线看网页网站优化公司大家好
  • 网站建设 长安镇精准营销推广
  • 资讯网站开发需求外贸网站平台
  • 和创客贴类似的网站百度网盘电脑版
  • 建立网站需要注意事项昆明seo建站
  • wordpress内置分页方法怎样优化关键词到首页
  • 做游戏网站要多少钱北京效果好的网站推广
  • wordpress 首页慢郑州技术支持seo
  • 东营网站建设培训百度搜索指数的数据来源
  • 洛阳市网站建设吉林网络推广公司
  • 网站建设如何做好整体色彩搭配营销策划的十个步骤
  • 网校网站毕业设计的方案百度网盟推广官方网站
  • 江津区做网站网络推广技术外包
  • 网站独立开发360渠道推广系统
  • 网站建设江门软文发布门户网站
  • 学院网站建设流程百度开放平台登录
  • 手机文章网站源码关键词免费
  • 成都网站建设详细内容大众点评seo关键词优化
  • 网站建设帮助中心深圳百度网站排名优化
  • 然后建设一个论坛网站网络营销课程总结
  • 郑州网站建设报价网站建设技术
  • php做网站如何配置域名的私人网站服务器
  • 青岛网站建设方案维护广告公司注册
  • 网站要有可留言功能 怎么做浙江专业网站seo
  • 网站域名使用费用南京百度推广优化