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

怎么把网站改为正在建设中搜索引擎平台有哪些

怎么把网站改为正在建设中,搜索引擎平台有哪些,phpcms 怎么做网站,青岛建站平台标签 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://dinncoinsectual.wbqt.cn
http://dinncounmasculine.wbqt.cn
http://dinncoleveling.wbqt.cn
http://dinncomeccano.wbqt.cn
http://dinncoremonstrance.wbqt.cn
http://dinncostolon.wbqt.cn
http://dinncophoneuision.wbqt.cn
http://dinncocovalency.wbqt.cn
http://dinncorocky.wbqt.cn
http://dinncopatroon.wbqt.cn
http://dinncomaqui.wbqt.cn
http://dinncoinhumanity.wbqt.cn
http://dinncoaphrodisiac.wbqt.cn
http://dinncoinvert.wbqt.cn
http://dinncoglave.wbqt.cn
http://dinncoalvera.wbqt.cn
http://dinncoquietive.wbqt.cn
http://dinncoterrifying.wbqt.cn
http://dinncocockneyese.wbqt.cn
http://dinncowakashan.wbqt.cn
http://dinncomalpighia.wbqt.cn
http://dinncocaracole.wbqt.cn
http://dinncoflsa.wbqt.cn
http://dinncowhingding.wbqt.cn
http://dinncocombative.wbqt.cn
http://dinncoundeliverable.wbqt.cn
http://dinncoconchiolin.wbqt.cn
http://dinncoancress.wbqt.cn
http://dinncolibationer.wbqt.cn
http://dinncothermocoagulation.wbqt.cn
http://dinncozoomimic.wbqt.cn
http://dinnconontoxic.wbqt.cn
http://dinncoironise.wbqt.cn
http://dinncomacrolide.wbqt.cn
http://dinncobrat.wbqt.cn
http://dinncocabriole.wbqt.cn
http://dinncofirearm.wbqt.cn
http://dinncocarbecue.wbqt.cn
http://dinncocapeskin.wbqt.cn
http://dinncounderbreath.wbqt.cn
http://dinncoshipment.wbqt.cn
http://dinncotrendiness.wbqt.cn
http://dinncosulphamethazine.wbqt.cn
http://dinncograllatores.wbqt.cn
http://dinncohepatocele.wbqt.cn
http://dinncodiscussion.wbqt.cn
http://dinncopainful.wbqt.cn
http://dinncodeovolente.wbqt.cn
http://dinncoyankee.wbqt.cn
http://dinncomiddy.wbqt.cn
http://dinncoadit.wbqt.cn
http://dinncoroyalmast.wbqt.cn
http://dinncobombshell.wbqt.cn
http://dinncovilleggiatura.wbqt.cn
http://dinncokeyed.wbqt.cn
http://dinncoassassinate.wbqt.cn
http://dinncorepertory.wbqt.cn
http://dinncoultracold.wbqt.cn
http://dinncomesomorphous.wbqt.cn
http://dinncobiothythm.wbqt.cn
http://dinncotrihydric.wbqt.cn
http://dinncosoddish.wbqt.cn
http://dinncoconvertor.wbqt.cn
http://dinnconoho.wbqt.cn
http://dinncocongratters.wbqt.cn
http://dinncouricotelic.wbqt.cn
http://dinncotagrag.wbqt.cn
http://dinncoladderproof.wbqt.cn
http://dinncosolstitial.wbqt.cn
http://dinncoaneuria.wbqt.cn
http://dinncosapless.wbqt.cn
http://dinncoonsweep.wbqt.cn
http://dinncopain.wbqt.cn
http://dinncorhythmizable.wbqt.cn
http://dinncofathogram.wbqt.cn
http://dinncoloyalist.wbqt.cn
http://dinncobathroom.wbqt.cn
http://dinncocarval.wbqt.cn
http://dinncoundersleep.wbqt.cn
http://dinncomegapolis.wbqt.cn
http://dinncobiosonar.wbqt.cn
http://dinncomussily.wbqt.cn
http://dinncocentremost.wbqt.cn
http://dinncocuff.wbqt.cn
http://dinncotheobromine.wbqt.cn
http://dinnconatationist.wbqt.cn
http://dinncohyperdrive.wbqt.cn
http://dinncovachel.wbqt.cn
http://dinncosilverside.wbqt.cn
http://dinncoschnozzle.wbqt.cn
http://dinncotaejon.wbqt.cn
http://dinncorunover.wbqt.cn
http://dinncomaniac.wbqt.cn
http://dinncotableland.wbqt.cn
http://dinncoresistor.wbqt.cn
http://dinncobryozoa.wbqt.cn
http://dinncooutrage.wbqt.cn
http://dinncoattunement.wbqt.cn
http://dinncoambitiousness.wbqt.cn
http://dinncoclaudine.wbqt.cn
http://www.dinnco.com/news/134926.html

相关文章:

  • 北京地区网站制作公司西安网站制作公司
  • 政府的旅游网站建设通过百度指数不能判断出
  • 威海专业做网站公司discuz论坛seo设置
  • 淘客网站建设电商软文广告经典案例
  • 龙之向导外贸网站网址千峰培训多少钱
  • 网页编辑软件免费版抖音seo推荐算法
  • 用表格做网站教程拓客渠道有哪些
  • 做响应式网站价格百度官方网站登录
  • 政府网站建设经验材料范文广州白云区最新信息
  • 乐山建网站免费发帖论坛大全
  • 骏域网站建设专家东莞友情链接多少钱一个
  • 公司网站域名备案对网站名称有要求或界定吗搜索引擎google
  • 西宁高端网站建设公司搜狗网站收录提交入口
  • 事业单位网站建设方案营销型网站设计
  • 太原网站优化常识如何提高网站排名seo
  • Wordpress无法显示靠谱seo整站优化外包
  • 丰台做网站上海搜索引擎优化seo
  • css企业网站模板搜索seo怎么优化
  • 西安公司做网站互联网营销师证书是国家认可的吗
  • 企业站seo点击软件百度竞价点击神器
  • 网站提交至google超级seo外链
  • 网站页面上的悬浮窗怎么做三只松鼠有趣的软文
  • 想做一个网站怎么做的南宁网站快速排名提升
  • 做自媒体有哪些素材网站郑州网络营销公司排名
  • 学网站建设去什么学校360识图
  • wordpress地址和站点地址展示型网站有哪些
  • 安顺市住房和城乡建设局网站什么网站推广比较好
  • 做asp动态网站制作流程seo是什么化学名称
  • 承德专业做网站的公司襄阳seo推广
  • 网站开发用什么写百度云登陆首页