StrutsSpringObjectFactory默认注入策略

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

你可能感兴趣的:(java,spring,Hibernate,struts)