struts1与spring注解

我们在使用Sturts1.x的时候需要在struts-config.xml中配置Action,使用的方式如下:

...... ......

客户端则通过如下方式调用此Action:

...

而使用Spring之后,可以使用Spring提供的@Contorller注解代替 type="对应的Action包.类名"

@Controller("control/product/type/list") // 此处必须与配置中的Action的path属性值一致 public class ProductTypeAction extends Action { ...... }

到此处视乎已经完成,但是最重要的还没有出现,Spring之所以强大时因为它能很好的为其它框架服务(Struts/Hibernate),在启动服务器的时候,通过以下配置,Spring将扫描指定包下的类文件,通过注解的方式获得需要的资源(@Service/@Controller/@Component等),省去了在xml中配置的麻烦,提高了开发的效率。

// struts-confing.xml 以上的配置为了让@Controller注解起作用 此外还需要早applicationContext.xml中加入:

你可能感兴趣的:(Spring,Struts,配置管理,Hibernate,XML)