SpringMVC——常用注解
引言: SpringMVC 注解开发是一种springmvc的便捷方式,通过注解降低了配置文件的复杂性。 概述: SpringMVC常用的注解有很多,我们今天只总结最常用的几个注解,主要包括注解的含义和作用以及相似注解的区别与联系。 内容: 一 @Controller 1 含义:Controller代表控制层, @Controller定义控制层的bean。 2 作用: 定义Controller的bean,无需继承特定的类或者实现特定的接口(public class ItemsController implements Controller),只需要使用@Controller标记一个类是Controller即可,如下所示 @Controller Public class ItemsController{}; 3 说明:我们单纯使用@Controller标记一个类并不能真正将该类定义为SpringMVC的一个控制类,需要把它交给Spring来管理才行,也就是在SpringMVC配置文件(springmvc.xml)中进行配置。 (1)在SpringMVC的配置文件中定义类的bean对象 <bean id="itemsController" name="/queryItems_test.action" class="cn.itcast.ssm.controller