Strust2 框架中的问题备忘录
Strust2 internal? Container 如何将spring容器中的bean注入到静态类中的?
?
在struts-plugin.xml这个文件中的配置信息,如下:
?
?
?
type一般是一组bean的接口,而class 是每个bean的实现类,而name则是这些bean的具体名字,这个名字起到了这个配置项目的identity作用。
?
在java代码中当在上下文中拿到container对象之后,可以通过如下方式来操作配置在struts2配置文件中的bean:
?
?
?同样是org.apache.struts2.dispatcher.mapper.ActionMapper 这个接口,但是有四种不同的实现,但是在org.apache.struts2.dispatcher.FilterDispatcher
@Injectpublic void setTestInterface(ITestInterface testInterface) {this.testInterface = testInterface;}?会把名字为name为default的实现版本注入到action中,这样问题又来了,在默认的struts-default.xml文件中有配置的bean的name并不是以default开头的,那他们是按照怎么一个规则被注入到别的bean中的呢?
这个可以查看一下 struts.properties 配置文件 http://struts.apache.org/2.0.11/docs/strutsproperties.html
?
?