PetClinic 学习资料

1. 官方教程

http://docs.spring.io/docs/petclinic.html



1.1 请求控制器

翻译:

下面的这些Bean类,对于请求控制器来说都是可以访问的,并且,它们在petclinic-servlet.xml这个文件里被定义。

请求控制器使用这些定义把实际的显示和表单处理任务委派给业务控制器类。DispatcherServlet扮演一个请求控制器的角色,通过url映射来转发所有的请求给合适的业务控制器。

业务控制器负责与用户交互,并且把最终的action委派给业务/持久层。


  • 国际化的配置文件

  • 逻辑视图路径与实际视图路径的映射

  • 基于表单的业务控制器和非表单业务控制器



原文

DispatcherServlet

The following beans are accessible to the DispatcherServlet and are defined in the PetClinic petclinic-servlet.xml file. This dispatcher uses these definitions to delegate actual display and form processing tasks to implementations of the Spring org.springframework.web.servlet.mvc.Controller interface. The DispatcherServlet acts as the main application Front Controller and is responsible for dispatching all requests to the appropriate Controller indirectly through a URL mapping handler. These Controllers are responsible for the mechanics of interaction with the user and ultimately delegate action to the Business/Persistence Layers.

  • messageSource is a singleton bean that defines a message source for this ApplicationContext. Messages are loaded from localized "messages_xx" files in the classpath, such as "/WEB-INF/classes/messages.properties" or "/WEB-INF/classes/messages_de.properties".  getMessage() calls to this context will use this source. Child contexts can have their own message sources, which will inherit all messages from this source and are able to define new messages and override ones defined in the primary message source.

  • InternalResourceViewResolver is a singleton bean that defines the view mappings used by the dispatcher. Specifically, logical view names returned by Controllers will be mapped to physical paths using the configured 'prefix' and 'suffix' properties. For example, a logical view name of "vets" will be mapped to "/WEB-INF/jsp/vets.jsp".

  • SimpleMappingExceptionResolver is a singleton bean that defines how exceptions are propagated. Exceptions encountered that are not specified are propagated to the servlet container.

  • <context:component-scan ... /> is used to autodetect the controllers in the org.springframework.samples.petclinic.web package, which are POJOs labeled with the@Controller  annotation.

    • ClinicController is a singleton, annotation-driven MultiActionController that is used by the dispatcher to handle non-form based display tasks. A method is provided to handle each type of request that is supported.

    • In addition, there are 6 singleton, annotation-driven Form controllers, which are used to handle the various Search, Add and Edit form processing tasks for the dispatcher.

  • The form-based controllers within the PetClinic application provide @RequestMapping annotations at the type level for path mapping URLs and @RequestMapping at the method level for request type mappings (e.g., GET and POST). In contrast, ClinicController – which is not form-based – provides @RequestMapping only at the method level for path mapping URLs. DefaultAnnotationHandlerMapping is driven by these annotations and is enabled by default with Java 5+.


1.2 业务逻辑层/持久层

翻译:

PetClinic业务逻辑很少,该示例项目主要是展示持久化层。但是没有展示ibatis,展示ibatis是在JPetStore这个示例项目。


原文:

Business / Persistence Layer

Since the PetClinic application is all about database access and there is very little business logic in the application outside of that, there is no separation of the primary Business and Persistence Layer API's. While this design technique should not be used for an application with more complex business logic, it is acceptable here because all of the non-persistence related business rules have been implemented in business objects and have not leaked into the Persistence Layer. The most important facet of the design is that the Business and Persistence Layers are COMPLETELY independent of the Presentation Layer.

The Persistence Layer can be configured to use either HSQL or MySQL with any one of the following data access technologies aided by infrastructure provided by Spring:

  • JDBC

  • Hibernate 3

  • Java Persistence API(JPA)



NOTE: Spring also provides infrastructure for using other Object/Relational Mapping frameworks such as JDO and iBATIS SqlMaps, but these are not demonstrated in PetClinic. (See the 'jpetstore' sample application that ships with the full Spring Framework distribution for an example of using iBatis and Spring.)





2.PetClinic在github上的介绍

http://spring.io/blog/2013/03/21/spring-petclinic-is-on-github/


转载于:https://my.oschina.net/diedai/blog/519060

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值