|
1 | 1 | # mybatis-test
|
2 | 2 | **mybatis源码研究-2019/12/04**
|
3 |
| - |
4 |
| -***主要参考资料:*** |
5 |
| -> - [x] [MyBatis技术内幕 徐郡明 2017/07](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "提取码是fcak") |
6 |
| -> - [x] [MyBatis 3 源码深度解析 江荣波 2019/10](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "最新出版没有电子书") |
7 |
| -> - [x] [MyBatis从入门到精通 刘增辉 2017/07](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "提取码是fcak") |
8 |
| -> - [x] [深入浅出MyBatis 技术原理与实战 杨开振 2016/09](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "提取码是fcak") |
9 |
| -> - [x] [xml](https://www.w3school.com.cn/xml/index.asp "W3CSchool") |
10 |
| -> - [x] [dtd](https://www.w3school.com.cn/dtd/dtd_entities.asp "W3CSchool") |
11 |
| -> - [x] [schema](https://www.w3school.com.cn/schema/index.asp "W3CSchool") |
12 |
| -> - [x] [xpath](https://www.w3school.com.cn/xpath/xpath_nodes.asp "W3CSchool") |
13 |
| -> - [x] [XML入门经典(第5版) 第I部分-->第III部分](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
14 |
| -> - [x] [疯狂XML讲义](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
15 |
| -> - [x] [XML揭秘 入门·应用·精通 Michael Morrison 陆新年](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
16 |
| -> - [x] [《XML简明教程》2009年清华大学出版社出版 张欣毅](https://www.baidu.com "xml基础简明教程,没找到电子版。") |
17 |
| -
|
18 | 3 |
|
19 | 4 | ***mybatis整体架构***
|
20 |
| -> mybatis整体架构分为三层,分别是基础支持层、核心处理层和接口层。 |
21 |
| ->  |
22 | 5 |
|
23 |
| -***mybatis思维导图*** |
24 |
| ->  |
| 6 | +mybatis整体架构分为三层,分别是基础支持层、核心处理层和接口层。 |
| 7 | +>  |
25 | 8 |
|
26 |
| - |
27 |
| -# XML基础知识 |
| 9 | +**** |
| 10 | +# XML基础知识(名称空间/文档验证/文档处理) |
28 | 11 |
|
29 | 12 | ## XML
|
30 | 13 | 所有的 XML 文档(以及 HTML 文档)均由以下简单的构建模块构成:
|
|
40 | 23 |
|
41 | 24 | ## DTD(Document Type Definition)
|
42 | 25 |
|
| 26 | +参考资料: |
| 27 | +> [XML入门经典(第5版) 第I部分-->第III部分](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
| 28 | +
|
43 | 29 | 文档类型声明或DOCTYPE告诉解析器,XML文档必须遵循DTD定义。同时它也告诉解析器,到哪里找到文档定义的其余内容。
|
44 | 30 | `<!DOCTYPE name [ ]>`
|
45 | 31 |
|
@@ -96,3 +82,123 @@ ATTLIST包含三个部分:ATTLIST关键字 相应元素名 属性列表
|
96 | 82 | 上面例子指出book元素包含year属性,CDATA用来定义属性类型,#IMPLIED指出该属性不是必须的。
|
97 | 83 | `ref: https://www.w3school.com.cn/dtd/dtd_attributes.asp`
|
98 | 84 |
|
| 85 | +## schema |
| 86 | +XML Schema 参考手册: |
| 87 | +> https://www.w3school.com.cn/schema/schema_elements_ref.asp |
| 88 | +
|
| 89 | + XML Schema 是基于 XML 的 DTD 替代者。XML Schema也称为XML框架或XML模式。通过Schema可以描述和规范XML文档的数据模式和组织结构,规定 |
| 90 | + XML文档中可以包含哪些元素、这些元素拥有哪些子元素及其出现的顺序和次数,还规定每个元素和属性的数据类型。与DTD相比,通过XML Schema可以 |
| 91 | + 更好地规范和验证有效的XML文档。 |
| 92 | + XML Schema总是以独立文档形式存在,其文件扩展名为.xsd。XML Schema文档本身就是一个符合XML规范的、格式良好的XML文档,该文档通过一套预先 |
| 93 | + 定义的XML元素及其属性创建的,正是这些特定的元素和属性规定了XML文档的结构和内容模式。 |
| 94 | + |
| 95 | +Schema文档从一个XML文档声明开始,其后的内容是对根元素schema的声明。根据需要,还可以从一个Schema文档中包含或导入其他Schema文档。 |
| 96 | +eg. http://www.springframework.org/schema/beans/spring-beans-4.1.xsd 文档基本框架如下: |
| 97 | +```xml |
| 98 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 99 | +<xsd:schema xmlns="http://www.springframework.org/schema/beans" |
| 100 | + xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
| 101 | + targetNamespace="http://www.springframework.org/schema/beans"> |
| 102 | + |
| 103 | + <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/> |
| 104 | + <!--元素和属性声明--> |
| 105 | +</xsd:schema> |
| 106 | +``` |
| 107 | + xmlns:指定该schema的默认名称空间 |
| 108 | + targetNamespace:声明了在该xsd文档下定义的元素属于该命名空间 |
| 109 | + schemaLocation:告诉验证器去哪里找到可用于验证的XML Schema文档 |
| 110 | + |
| 111 | +举个栗子: |
| 112 | +```java |
| 113 | + /** Default Servlet name used by Tomcat, Jetty, JBoss, and GlassFish */ |
| 114 | + private static final String COMMON_DEFAULT_SERVLET_NAME = "default"; |
| 115 | + /** Default Servlet name used by Google App Engine */ |
| 116 | + private static final String GAE_DEFAULT_SERVLET_NAME = "_ah_default"; |
| 117 | + /** Default Servlet name used by Resin */ |
| 118 | + private static final String RESIN_DEFAULT_SERVLET_NAME = "resin-file"; |
| 119 | + /** Default Servlet name used by WebLogic */ |
| 120 | + private static final String WEBLOGIC_DEFAULT_SERVLET_NAME = "FileServlet"; |
| 121 | + /** Default Servlet name used by WebSphere */ |
| 122 | + private static final String WEBSPHERE_DEFAULT_SERVLET_NAME = "SimpleFileServlet"; |
| 123 | +``` |
| 124 | +如果web.xml中配置了某个servlet拦截了所有的请求,那么一些静态资源的访问如jpg,css,js也会被处理。 |
| 125 | +```xml |
| 126 | +<servlet-mapping> |
| 127 | + <servlet-name>default</servlet-name> |
| 128 | + <url-pattern>*.jpg</url-pattern> |
| 129 | +</servlet-mapping> |
| 130 | +<servlet-mapping> |
| 131 | + <servlet-name>default</servlet-name> |
| 132 | + <url-pattern>*.js</url-pattern> |
| 133 | +</servlet-mapping> |
| 134 | +<servlet-mapping> |
| 135 | + <servlet-name>default</servlet-name> |
| 136 | + <url-pattern>*.css</url-pattern> |
| 137 | +</servlet-mapping> |
| 138 | +``` |
| 139 | +在springMVC-servlet.xml中配置:<mvc:default-servlet-handler/> 这个元素声明在:http://www.springframework.org/schema/mvc/spring-mvc.xsd(FAQ. 自动匹配xsd版本?) |
| 140 | +```xml |
| 141 | +<xsd:element name="default-servlet-handler"> |
| 142 | + <xsd:annotation> |
| 143 | + <xsd:documentation |
| 144 | + source="java:org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler"><![CDATA[ |
| 145 | + Configures a handler for serving static resources by forwarding to the Servlet container's default Servlet. Use of this |
| 146 | + handler allows using a "/" mapping with the DispatcherServlet while still utilizing the Servlet container to serve static |
| 147 | + resources. |
| 148 | + This handler will forward all requests to the default Servlet. Therefore it is important that it remains last in the |
| 149 | + order of all other URL HandlerMappings. That will be the case if you use the "annotation-driven" element or alternatively |
| 150 | + if you are setting up your customized HandlerMapping instance be sure to set its "order" property to a value lower than |
| 151 | + that of the DefaultServletHttpRequestHandler, which is Integer.MAX_VALUE. |
| 152 | + ]]></xsd:documentation> |
| 153 | + </xsd:annotation> |
| 154 | + <xsd:complexType> |
| 155 | + <xsd:attribute name="default-servlet-name" type="xsd:string"> |
| 156 | + <xsd:annotation> |
| 157 | + <xsd:documentation><![CDATA[ |
| 158 | + The name of the default Servlet to forward to for static resource requests. The handler will try to auto-detect the container's |
| 159 | + default Servlet at startup time using a list of known names. If the default Servlet cannot be detected because of using an unknown |
| 160 | + container or because it has been manually configured, the servlet name must be set explicitly. |
| 161 | + ]]></xsd:documentation> |
| 162 | + </xsd:annotation> |
| 163 | + </xsd:attribute> |
| 164 | + </xsd:complexType> |
| 165 | + </xsd:element> |
| 166 | +``` |
| 167 | +删除文档注释,可以看到*复合类型元素default-servlet-handler*包含一个*default-servlet-name属性*,通过转发请求到Servlet容器的default-servlet从而达到对静态资源的处理。 |
| 168 | +(具体实现请参考,笔者版本spring4.1.9:org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler) |
| 169 | +```xml |
| 170 | +<!--通过转发到Servlet容器的默认Servlet来配置用于提供静态资源的处理程序。--> |
| 171 | +<xsd:element name="default-servlet-handler"> |
| 172 | + <xsd:complexType> |
| 173 | + <xsd:attribute name="default-servlet-name" type="xsd:string"> |
| 174 | + </xsd:attribute> |
| 175 | + </xsd:complexType> |
| 176 | + </xsd:element> |
| 177 | +``` |
| 178 | +最后介绍一个xml/dtd转xsd工具[trang](https://pan.baidu.com/s/1BEhMthozcXUCnMRKvxi1pg "验证码:yc2a") |
| 179 | +```dos |
| 180 | +cd C:\Users\45554\Downloads\trang-20030619 |
| 181 | +java -jar .\trang.jar .\inventory.dtd inventory.xsd |
| 182 | +``` |
| 183 | +FAQ. 自行比较DTD与XML schema |
| 184 | +FAQ. 阅读其他主题XPath、xslt、DOM、Java与xml等 |
| 185 | +**** |
| 186 | + |
| 187 | +***mybatis思维导图*** |
| 188 | +>  |
| 189 | +
|
| 190 | +***主要参考资料:*** |
| 191 | +> - [x] [MyBatis技术内幕 徐郡明 2017/07](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "提取码是fcak") |
| 192 | +> - [x] [MyBatis 3 源码深度解析 江荣波 2019/10](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "最新出版没有电子书") |
| 193 | +> - [x] [MyBatis从入门到精通 刘增辉 2017/07](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "提取码是fcak") |
| 194 | +> - [x] [深入浅出MyBatis 技术原理与实战 杨开振 2016/09](https://pan.baidu.com/s/1-JGtoXADDjQRw5v51np4vA "提取码是fcak") |
| 195 | +> - [x] [xml](https://www.w3school.com.cn/xml/index.asp "W3CSchool") |
| 196 | +> - [x] [dtd](https://www.w3school.com.cn/dtd/dtd_entities.asp "W3CSchool") |
| 197 | +> - [x] [schema](https://www.w3school.com.cn/schema/index.asp "W3CSchool") |
| 198 | +> - [x] [xpath](https://www.w3school.com.cn/xpath/xpath_nodes.asp "W3CSchool") |
| 199 | +> - [x] [XML入门经典(第5版) 第I部分-->第III部分](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
| 200 | +> - [x] [疯狂XML讲义](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
| 201 | +> - [x] [XML揭秘 入门·应用·精通 Michael Morrison 陆新年](https://pan.baidu.com/s/1M3HSfL3VQgpVvHa_ekUjvQ "提取码是9mfm") |
| 202 | +> - [x] [《XML简明教程》2009年清华大学出版社出版 张欣毅](https://www.baidu.com "xml基础简明教程,没找到电子版。") |
| 203 | +> - [x] [Java与XML](https://www.baidu.com "java访问xml") |
| 204 | +
|
0 commit comments