很明显,这是将utf-8写成uft-8了- -#
<异常> java.lang.NoSuchMethodException: com.bjsxt.action.UserAction.execute()
解决方案:没有设置struts.xml中的method方法!!!在index.jsp的form表单name属性中设置也可以,例如name=user!add
<异常> Caused by: java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>
解决方案:将uri改为url
<异常> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver&&网页上显示java.lang.NullPointerException
解决方案:没有导入mysql.connection包!!!
<异常> Caused by: 需要属性 "name", 并且必须为元素类型 "package" 指定该属性。 - file:/F:/tools/apache-tomcat-7.0.69/webapps/bjsxt/WEB-INF/classes/struts.xml:15:56
解决方案:在struts.xml的package中设置name属性
<异常> org.hibernate.hql.ast.QuerySyntaxException: department is not mapped [from department]
解决方案:将hql语句from department改为from Department 注:HQL的关键字不区分大小写,类名与属性名是区分大小写的。
<异常>警告: Could not find action or result ,No result defined for action com.bjsxt.action.OrgAction and result success
解决方案:action 或result配置错误!
<异常>: could not initialize proxy - the owning Session was closed,org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
解决方案:设置lazy=false,或者延长session生命周期
<异常>:Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.bjsxt.po.User
解决方案:将HQL语句session.createQuery(" from User u left join u.department d where d.id=?")改为
session.createQuery("select u from User u left join u.department d where d.id=?"),前面必须加select u!!!u是别名!
<异常>无异常抛出,但是数据库表始终无法自动创建,hibernate.hbm2ddl.auto已设置为update
解决方案:User.hbm.xml文件class中table属性误写为t-user,改为t_user后正常
<异常>org.hibernate.exception.GenericJDBCException: could not insert: [com.bjsxt.po.User](connection is read-only)
解决方案:applicationContext.xml的transactionManager的事务特征描述:tx:method中加入业务层的方法前缀,如增加<tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT"/>