SqlSession sqlsession=null;
try{
sqlSession = dbAccess.getSqlSession();
}catch(){
e.printStackTrace();
}finally{
sqlSession.close();
}SqlSession sqlsession=null;为什么写在Try...catch语句外面?而不是
try{
SqlSession sqlSession = dbAccess.getSqlSession();
}
try 块是有他自己的作用域的,如果你变量定义在 try 里,在 try 块外部就不能使用了。