发现ajax在传递日期参数的时候,javascript已经默认的额toString()方法转为字符转格式了;
经过查阅资料发现:
ajax发送的请求参数和接收服务器端返回的数据都是文本数据,ajax不支持二进制数据传输,所以会调用toStirng()方法把参数转为字符串。 ajax的post和get的数据都是以文本方式传输,无论是客户端提交的数据还是服务器端返回的数据;
ajax传递日期类型的参数,传递的是日期类型的字符串,在后端代码中需要操作,将字符串转为日期类型;
接下来问题又出现了
:
当我按住日期参数查询数据库的时候,报错:
invalid comparison: java.util.Date and java.lang.String
感谢: https://www.cnblogs.com/dflmg/p/6641168.html
<select id="getIntegralCoefficientStockList" resultType="IntegralCoefficientStock" parameterType="IntegralCoefficientStock">
SELECT
coefficient_stock_id,
coefficient_stock,
create_time,
create_by,
stock_code
FROM integral_coefficient_stock
<where>
<if test="createTime!=null and createTime!=‘‘ ">
AND create_time = #{createTime}
</if>
<if test="stockCode!=null and stockCode!=‘‘ ">
AND stock_code like "%"#{stockCode}"%"
</if>
</where>
</select>
而正确的代码应该是这样的: <select id="getIntegralCoefficientStockList" resultType="IntegralCoefficientStock" parameterType="IntegralCoefficientStock"> SELECT coefficient_stock_id,coefficient_stock,create_time,create_by,stock_code FROM integral_coefficient_stock <where> <if test="1"> AND create_time = #{createTime} </if> <if test="stockCode!=null and stockCode!=‘‘ "> AND stock_code like "%"#{stockCode}"%" </if> </where> </select>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。