如下ibatis-news.xml:
<select id="queryNews" parameterClass="news" resultClass="news">
select chr_id,title,ctime,htis,type,image from news
<dynamic prepend="WHERE">
<isNotEmpty prepend="" property="chr_id">
<isNotEqual compareValue="" prepend="and" property="chr_id">
chr_id=#chr_id#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="title">
<isNotEqual compareValue="" prepend="and" property="title">
title=#title#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="ctime">
<isNotEqual compareValue="" prepend="and" property="ctime">
ctime=#ctime#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="htis">
<isNotEqual compareValue="" prepend="and" property="htis">
htis=#htis#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="type">
<isNotEqual compareValue="" prepend="and" property="type">
type=#type#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="image">
<isNotEqual compareValue="" prepend="and" property="image">
image=#image#
</isNotEqual>
</isNotEmpty>
</dynamic>
</select>
这样动态拼接一个语句,后来发现
加入 type是 int类型的。
现在在action中来根据 type做查询。type是int类型:
回报如下错误:
java.lang.NumberFormatException: For input string: ""
在页面看到如下信息:
javax.servlet.ServletException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
The error occurred in org/zwck/business/news/ibatis-news.xml. 这个怎么办 是不是因为 type是int类型的而出错了。
我试过任何String了类型的不会错,也就是说如果 type是String类型的那就不会错。
<select id="queryNews" parameterClass="news" resultClass="news">
select chr_id,title,ctime,htis,type,image from news
<dynamic prepend="WHERE">
<isNotEmpty prepend="" property="chr_id">
<isNotEqual compareValue="" prepend="and" property="chr_id">
chr_id=#chr_id#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="title">
<isNotEqual compareValue="" prepend="and" property="title">
title=#title#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="ctime">
<isNotEqual compareValue="" prepend="and" property="ctime">
ctime=#ctime#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="htis">
<isNotEqual compareValue="" prepend="and" property="htis">
htis=#htis#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="type">
<isNotEqual compareValue="" prepend="and" property="type">
type=#type#
</isNotEqual>
</isNotEmpty>
<isNotEmpty prepend="" property="image">
<isNotEqual compareValue="" prepend="and" property="image">
image=#image#
</isNotEqual>
</isNotEmpty>
</dynamic>
</select>
这样动态拼接一个语句,后来发现
加入 type是 int类型的。
现在在action中来根据 type做查询。type是int类型:
回报如下错误:
java.lang.NumberFormatException: For input string: ""
在页面看到如下信息:
javax.servlet.ServletException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
The error occurred in org/zwck/business/news/ibatis-news.xml. 这个怎么办 是不是因为 type是int类型的而出错了。
我试过任何String了类型的不会错,也就是说如果 type是String类型的那就不会错。
解决方案 »
- Java 动态二级域名 和 Tomcat 的问题
- No unique bean of type [com.dao.IBaseDAO] is defined: expecte
- java页面传值问题
- session问题
- applicationContext.xml文件中加入事务管理的代码,就出现Servlet action is not available错误
- Hibernate 子查询问题
- Exception in thread "main" java.sql.SQLException
- hibernate在SQL SERVER 2000找不到表
- 那里有介绍J2EE的中文网站?
- spring boot +spring security 4 报type=Forbidden, status=403
- java连接数据库的错误,请人指点
- 日志处理
<isNotEqual compareValue="" prepend="and" property="type">
type=#type#
</isNotEqual>
</isNotEmpty>
LZ有必要这么写嘛,不为空(或NULL)且不等空,直接
<isNotEmpty prepend="" property="type">
type=#type#
</isNotEmpty>
不就行了
type=#type#
</isNotEmpty>
这么写就没有那个问题了