springMVC详解以及注解说明(6)

2018-12-29 21:18

? Spring 支持以下4 种类型的过滤方式:

? 注解 org.example.SomeAnnotation 将所有使用SomeAnnotation 注解的类过滤出来

? 类名指定 org.example.SomeClass 过滤指定的类

? 正则表达式 com.kedacom.spring.annotation.web..* 通过正则表达式过滤一些类

? AspectJ 表达式 org.example..*Service+ 通过AspectJ 表达式过滤一些类

? 正则表达式的过滤方式举例:

base-package=\

expression=\spring.annotation.web..*\>

? 注解的过滤方式举例:

expression=\

expression=\

expression=\

启用Spring MVC 注解

? 启动Spring MVC 的注解功能,完成请求和注解POJO 的映射 ?

class=\odHandlerAdapter\ 注解介绍

? @Controller ? @Service ? @Autowired ? @RequestMapping

? @RequestParam ? @ModelAttribute ? @Cacheable ? @CacheFlush ? @Resource ? @PostConstruct ? @PreDestroy ? @Repository

? @Component (不推荐使用) ? @Scope

? @SessionAttributes ? @InitBinder

@Component是通用标注,@Controller标注web控制器,@Service标注Servicec层的服务,@Respository标注DAO层的数据访问

@Controller ? 例如 @Controller

public class SoftCreateController extends SimpleBaseController {}

? 或者

@Controller(\ ? 说明

@Controller 负责注册一个bean 到spring 上下文中,bean 的ID 默认为类名称开头字母小写 @Service ? 例如 @Service

public class SoftCreateServiceImpl implements ISoftCreateService {} ? 或者

@Service(\ ? 说明

@Service 负责注册一个bean 到spring 上下文中,bean 的ID 默认为类名称开头字母小写

@Autowired ? 例如 @Autowired

private ISoftPMService softPMService; ? 或者

@Autowired(required=false)

private ISoftPMService softPMService = new SoftPMServiceImpl();

? 说明

@Autowired 根据bean 类型从spring 上线文中进行查找,注册类型必须唯一,否则报异常。与@Resource 的区别在于,@Resource 允许通过bean 名称或bean 类型两种方式进行查找@Autowired(required=false) 表示,如果spring 上下文中没有找到该类型的bean 时, 才会使用new SoftPMServiceImpl();

@RequestMapping ? 类


springMVC详解以及注解说明(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:蚊虫类孽生规律及其防治

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: