---
title: "struts1与spring注解"
author: "lzc0088"
date: "2010-03-08T16:56:00Z"
tags: ["Hibernate", "Spring", "Struts", "XML", "配置管理"]
slug: "struts1-spring"
draft: false
lastmod: "2010-03-08T16:56:00Z"
id: 613161
url: "https://lzc0088.iteye.com/blog/613161"
---

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

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

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

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