public StrutsSpringObjectFactory(
@Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE,required=false) String autoWire,autoWire由构造方法注入,默认值为"name"
int type = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME; // default
if ("name".equals(autoWire)) {
type = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME;
} else if ("type".equals(autoWire)) {
type = AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE;
} else if ("auto".equals(autoWire)) {
type = AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT;
} else if ("constructor".equals(autoWire)) {
type = AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR;
} else if ("no".equals(autoWire)) {
type = AutowireCapableBeanFactory.AUTOWIRE_NO;
}
this.setAutowireStrategy(type);默认按名字注入
引起问题:接收页面数据的类如果有自身类型的属性抛异常
public class Category {
private String id;
private String name;
private String description;
private Category parent;
private Set<Category> children;异常为:
Struts has detected an unhandled exception:
# Messages: attempt to create saveOrUpdate event with null entity
File: org/hibernate/event/SaveOrUpdateEvent.java
本文探讨了在使用Struts框架结合Spring时遇到的一个异常情况,即在尝试创建、保存或更新实体对象时出现空指针异常的问题。该问题与自动装配策略有关,并通过Category类的具体实例展示了错误的发生及可能的原因。
1112

被折叠的 条评论
为什么被折叠?



