@Controller是对应控制层的<bean>,也就是action类用法:1 @Controller2 @Scope("prototype")3 public class NewsAction extends ActionSupport{4 ……5 }注意:如果@Controller不指定其value【@Controller】,则默认的bean名字为这个类的类名首字母小写,如果指定value【@Controller(value="UserAction")】或者【@Controller("UserAction")】,则使用value作为bean的名字。
2、(类)@ Service
@Service对应的是业务层Bean用法:1 @Service("NewsService")2 public class NewsServiceImpl implements NewsService {3 ………4 }
3、(类)@ Repository
@Repository对应数据访问层Bean,部分技术人员也喜欢叫dao类用法1 @Repository(value="NewsDao")2 public class NewsDaoImpl extends NewsDaoImpl {3 ………4 }注意:以上三种(@Controller、@Service、@Repository)是针对不同层的类所使用的注解,下面的是针对属性所使用的注解: