PetClinic 学习资料

Stella981
• 阅读 559

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/

点赞
收藏
评论区
推荐文章
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Easter79 Easter79
3年前
springboot项目 设置linux服务启动
官方文档https://docs.spring.io/springboot/docs/current/reference/htmlsingle/deploymentinstall(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fdocs.spring.io%2Fspringb
Stella981 Stella981
3年前
Spring Security学习
GettingStart官方文档学习SpringSecurityReference(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fdocs.spring.io%2Fspringsecurity%2Fsite%2Fdocs%2F
Stella981 Stella981
3年前
CodeBlocks中文版使用手册
原手册下载:http://www.codeblocks.org/docs/manual\_en.pdf(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fwww.codeblocks.org%2Fdocs%2Fmanual_en.pdf)   译者:JGood(http://blog
Wesley13 Wesley13
3年前
4. Nginx模块
Nginx官方模块1.ngx\_http\_stub\_status\_modulehttp://nginx.org/en/docs/http/ngx\_http\_stub\_status\_module.html。(https://www.oschina.net/action/GoToLink?urlhttp%3A%2
Wesley13 Wesley13
3年前
P2P技术揭秘.P2P网络技术原理与典型系统开发
Modular.Java(2009.06)\.Craig.Walls.文字版.pdf:http://www.t00y.com/file/59501950(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fwww.t00y.com%2Ffile%2F59501950)\More.E
Easter79 Easter79
3年前
Swift项目兼容Objective
!456.jpg(http://static.oschina.net/uploads/img/201509/13172704_1KcG.jpg"1433497731426906.jpg")本文是投稿文章,作者:一叶(博客(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2F00red
Easter79 Easter79
3年前
Springboot引用外部配置文件
Springboot官方文档(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fdocs.spring.io%2Fspringboot%2Fdocs%2FcurrentSNAPSHOT%2Freference%2Fhtmlsingle%2F%23bootfeaturesexte
Stella981 Stella981
3年前
Seata
seataserver为seata中的事务协调器。参考:http://seata.io/enus/docs/ops/deployserver.html(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fseata.io%2Fenus%2Fdocs%2Fops%2Fdeploys
Stella981 Stella981
3年前
Centos7使用yum安装Marathon
官方提供了两种安装方式(http://mesosphere.github.io/marathon/docs/(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fmesosphere.github.io%2Fmarathon%2Fdocs%2F)),一种是下载压缩包解压,一种是使用yum(h