问题描述
Ibatis在xml中动态查询时如果parameterClass="java.lang.String"怎么判断传入的字符串是否为空?
解决方案
解决方案二:
isNotEmpty
解决方案三:
哦,我知道是<isNotNull>、<isNotEmpty>关键是里面的property=什么?<isNotNull><isNotEmptyprepend="AND"property="?????"condition1=#ID#</isNotEmpty></isNotNull>
解决方案四:
在告诉你一种写法.<iftest="sttp!=null">andSTTP=#{sttp}</if>
解决方案五:
property不还是你传过来的str哦
解决方案六:
property对应你传的值,就你写的property=ID
解决方案七:
Causedby:org.xml.sax.SAXParseException:组件“select”不允许“if”--(#PCDATA|include|dynamic|iterate|isParameterPresent|isNotParameterPresent|isEmpty|isNotEmpty|isNotNull|isNull|isNotEqual|isEqual|isGreaterThan|isGreaterEqual|isLessThan|isLessEqual|isPropertyAvailable|isNotPropertyAvailable)atorg.apache.crimson.parser.Parser2.error(Parser2.java:3354)atorg.apache.crimson.parser.ValidatingParser$MixedValidator.consume(ValidatingParser.java:327)atorg.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497)atorg.apache.crimson.parser.Parser2.content(Parser2.java:1963)atorg.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)atorg.apache.crimson.parser.Parser2.content(Parser2.java:1963)atorg.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)atorg.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)atorg.apache.crimson.parser.Parser2.parse(Parser2.java:337)atorg.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)atorg.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)atcom.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:147)atcom.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:49)...56more
解决方案八:
<typeAliasalias="Mydocs"type="com.dt.sys.fulltext.pojo.Mydocs"/><resultMapid="MydocsResult"class="Mydocs"><resultcolumn="id"property="id"javaType="java.lang.Integer"jdbcType="int"nullValue="0"/><resultcolumn="title"property="title"javaType="java.lang.String"jdbcType="varchar"/><resultcolumn="thefile"property="thefile"javaType="java.lang.String"jdbcType="varchar"/></resultMap><sqlid="where"><dynamicprepend="where"><isNotNullproperty="id"><isGreaterEqualprepend="and"property="id"compareValue="0">id=#id:int#</isGreaterEqual></isNotNull><isNotNullproperty="title"><isNotEmptyprepend="and"property="title">title=#title:varchar#</isNotEmpty></isNotNull><isNotNullproperty="thefile"><isNotEmptyprepend="and"property="thefile">thefile=#thefile:varchar#</isNotEmpty></isNotNull></dynamic></sql><selectid="findByMap"resultMap="MydocsResult"parameterClass="java.util.Map"overOrderBy="id">select*frommydocs<includerefid="com.dt.sys.fulltext.pojo.Mydocs.where"/></select>