异常汇总

<异常> java.io.UnsupportedEncodingException: The character encoding [uft-8] is not supported

很明显,这是将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"/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值