零配置strust2 找到问题了!
有些时候做个小实验发现struts2零配置老是出问题, 通过原码debug发现根本就没有加载那些加入了@action注解类, 这问题到底出现在哪里呢?
虽然一次一次查了strust2文档,但是还是没有解决,
后来认真的看下说明:发现下面这些话:
Let's expand on this example and add a code behind class. In order to do this we need to ensure that the Convention plugin is able to find our action classes. By default, the Convention plugin will find all action classes that implement com.opensymphony.xwork2.Action or whose name ends with the word Action in specific packages.
These packages are located by the Convention plugin using a search methodology. First the Convention plugin finds packages named struts, struts2, action or actions. Any packages that match those names are considered the root packages for the Convention plugin. Next, the plugin looks at all of the classes in those packages as well as sub-packages and determines if the classes implement com.opensymphony.xwork2.Action or if their name ends with Action (i.e. FooAction). Here's an example of a few classes that the Convention plugin will find:
看完之后,我很想哭, strust2也太差了
它的愿意是这样的,想要成功被加载必须 实现两个地方,
第一:把你写的类放入到struts, struts2, action or actions包下,
第二;实现action接口或者 继承actionSupport!
唉,还是要细心看文档啊!!