我有个想法,就是把在编程过程中的所遇到的Exception都收集起来,这样可以渐渐的减少,或者不在重复遇到这样的异常,或者在以后遇到是也可以立刻回忆起来产生这种异常的原因,以便快速解决。
我自己收集了一些,包括解决的方法,可能有的异常是很低级的,但是发生的场景有可能不一样。总之,一点一点积累吧,一方面提高自己,另一方面也希望我遇到的这些异常,也能帮助大家尽快解决问题。这就是我的目的。如果有不合理的解决方法,也希望大家给我指证。
当然,大家也可以把自己的异常也加进来,这样就是一个异常处理集合啦,毕竟一个人的力量是有限的,大家一起努力吧!
先贴一点异常,希望能起到抛砖引玉的作用。有些问题比较低级,但也是提醒自己不要再犯这样低级的错误!
1.
org.hibernate.PropertyValueException: not-null property references a null or transient value: netctoss.entity.Users.loginName
字面意思:一个不允许为Null的属性引用了一个为Null的或者无效的值。
原因:在***.hbm.xml中的
<property name="ProjPortfolioID" column="ProjPortfolioID"
type="big_decimal" not-null="true" length="10" />
中,not-null="true",这说明属性ProjPortfolioID 不允许为空,而在ActionForm中未给他赋值,则就为空,所以就会报错!
就是插数据的时候把相关联的对象new好
RightsAddForm rf = (RightsAddForm) form;
Rights right = rf.getRight();
Modules modules = new Modules();
modules.setName(rf.getModules());
Operations operations = new Operations();
operations.setName(rf.getOperations());
right.setModules(modules);
right.setOperations(operations);
rightsBiz.addRight(right);
return mapping.findForward("next");
2.
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'users0_.enrolldate' in 'field list'
这是由于字段名字命名不统一
3.
edit 时,读不到form中的数据 <html:text property="pricings.name" /> 后面不可添加 value 属性,因为首先回去查找该属性。
4.
java.lang.NullPointerException
at netctoss.action.UserServicesAction.list(UserServicesAction.java:28)
通过join fetch 查找
配置文件
spring beans : dao, biz
actions: path
struts action
5.
Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
option 要加标签 <html:option>