首页 > 技术文章 > 基于mybatis设计简单OA系统问题2

thyHome 2018-05-10 01:55 原文

1、<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<fmt:formatNumber>标签用于格式化数字,百分比,货币。

教程:

http://www.runoob.com/jsp/jstl-format-formatnumber-tag.html

 

 2、错误:

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 57

javax.el.PropertyNotFoundException: Property 'creatTime' not found on type com.duma.entity.User 

 

找到jsp页面

<fmt:formatDate value="${user.creatTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
为 private Date createTime;
原因:jsp页面属性值拼写错误T T

 

3、插入的id类型为String不会报错

 

原因:进行select的时候发现,mysql可以直接对int字段传string类型值。Mysql会将传入的string(要赋值给int字段的)从左到右的第一个非数值开始,将后面的字符串转成0,在和数值类型相加,如上述例子就是“12abc”->12+0=12,也就是等效于select * from student where id=12。

有此可知传入string类型数据可能传入的不是我们要的int值,所以传入string类型有意外风险,所以需要传入int类型数据。

mysql在类型不同的情况下他会自动进行类型转换,这不光是在数据插入的时候才会做,在数据更新、查询和删除的时候都会这么做。

 

扩展:MySQL在查询时候加‘’对性能的影响

http://www.zendstudio.net/archives/single-quotes-or-no-single-quotes-in-sql-query/

 

4、优化:将查询结果先放到展示页面

 

然后通过链接转跳到修改界面,减少误操作。因为前后两次获得的数据一致可以链接同一个servlet,可以通过判断request的请求头来确定转跳的jsp页面

 

 5、Log4j

博客:

http://www.cnblogs.com/shwen99/archive/2007/12/29/1019853.html

推荐阅读