1. 报错:
07-Nov-2015 20:34:03.054 WARNING [http-nio-8080-exec-2] com.opensymphony.xwork2.util.logging.jdk.JdkLogger.warn couldn't clear tomcat cache
java.lang.NoSuchFieldException: resourceEntries
----------------------------------
tomcat8.0的类加载器webappclsaaLoader中没有属性resourceEntries,换成7就没有这个警告了
2. 报错:select * from book where cid=8 and bname like '%python%' and ISBN=limit 0,20
检查以后发现ISBN那行明明是string,结果我用了book.getIsbn()!=null 来做判定,自然报错了!
<span style="color:#333333;"> String sql="select * from book where cid="+book.getCid();
if(</span><span style="color:#cc0000;">book.getBname()!=null</span><span style="color:#333333;">){
sql+=(" and bname like '%" + book.getBname() + "%'");
}
if(!book.getIsbn().equals("")){
sql+=(" and ISBN="+book.getIsbn());
}
if(!book.getAuthor().equals("")){
sql+=(" and author like '%"+book.getAuthor()+"%'");
}
if(!book.getPublisher().equals("")){
sql+=(" and publisher like '%"+book.getPublisher()+"%'");
}</span>
3.进入首页时自动加载action。
百度了下,有很多种方法。
1.ajax异步调用,返回json
2.window.location.href="你的action地址";
3....
4.jsp
<a href="detail?bid=<s:property value='#book.bid'/>">detail</a>
我的BookAction implements ModelDriven<Book>
但是很多情况传的参数很少,我虽然写了modeldriven,但是还是private int bid; setter和getter了。
结果在action中这个bid取不到!!!
后来我把jsp中的bid改了名字才取到,我认为是java自动reflect到book对象中导致这个bid没有值,所以我又用book.bid尝试了下,果然可以取到值,那就应该是modeldriven的问题了。
有modeldriven的话,重复的变量就不要再定义了。
5.
public void convertCategoryToCid(Connection conn,String category,Book book) throws SQLException{
String sql="select cid from category where cname='"+category+"'";
PreparedStatement pstmt1 = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = pstmt1.executeQuery();
while (rs.next()) {
book.setCid(rs.getInt(1));
}
}
当category为Children's Books时,报错:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Books'' at line 1
确实:
select cid from category where cname='Children's Books';
网上很多解决方案。
不要拼sql,后患无穷。