通过 SpringMVC Date 参数实例化的配置实例,梳理和分析类型转换在 Spring 框架中的实现过程。
Spring 内置的类型转换实现组件,可以通过以下接口追溯
org.springframework.core.convert.converter.Converter
java.beans.PropertyEditor
org.springframework.beans.TypeConverterDelegate Spring 内部类型转换工具类
org.springframework.core.convert.support.GenericConversionService 类型转换器默认实现,可以直接注入使用。
记录 Mybatis 动态 SQL、字符串替换相关的实现,方便后续源码阅读和借鉴。
[MyBatis 3 | Dynamic SQL](https://mybatis.org/mybatis-3/dynamic-sql.html) |
One of the most powerful features of MyBatis has always been its Dynamic SQL capabilities. OGNL based expressions.
<select id="findActiveBlogLike" resultType="Blog">
SELECT * FROM BLOG
<!-- 只有在包含的标签返回任何内容时才会插入"WHERE"子句。如果内容以"AND"或"OR"开头,自动会将其去掉。 -->
<where>
<if test="title != null">
AND title like #{title}
</if>
<if test="author != null and author.name != null">
AND author_name like #{author.name}
</if>
</where>
</select>
// org.apache.ibatis.scripting.xmltags.XMLScriptBuilder#initNodeHandlerMap
private void initNodeHandlerMap() {
nodeHandlerMap.put("trim", new TrimHandler());
nodeHandlerMap.put("where", new WhereHandler());
nodeHandlerMap.put("set", new SetHandler());
nodeHandlerMap.put("foreach", new ForEachHandler());
nodeHandlerMap.put("if", new IfHandler());
nodeHandlerMap.put("choose", new ChooseHandler());
nodeHandlerMap.put("when", new IfHandler());
nodeHandlerMap.put("otherwise", new OtherwiseHandler());
nodeHandlerMap.put("bind", new BindHandler());
}
// dynamic SQL in annotated mapper class
@Select("select * from user where name = #{name} ORDER BY ${columnName}")
User findByName(@Param("name") String name);
使用 #{}
语法可以生成 PreparedStatement 属性,参数注解替换为 PreparedStatement参数(占位符?)。防止 SQL 拼接注入等安全问题。
使用 ${}
语法直接将未修改的字符串替换到SQL语句中,MyBatis不会修改或转义字符串。当 SQL 语句中的元数据(即表名或列名)是动态的时,字符串替换非常有用。
一切要从 Testing your GitHub Pages site locally with Jekyll 说起。跟着官方教程认真学习一番。
尝试不同的技术栈,并且可以让个人主页更加的定制化。
Jekyll is a Ruby Gem(Ruby 模块)。
需要在本地调试验证,需要环境准备,否则直接跳过。
Jekyll on Windows 先安装Ruby,再下载 Jekyll 模块。
一定要选择 Ruby+Devkit 版本。
安装Jekyll 命令 gem install jekyll bundler
Jekyll is a static site generator with built-in support for GitHub Pages.
创建Jekyll 工程命令 jekyll new --skip-bundle .
类似于 vue init; django-admin startproject。会准备一个site 框架。
其中,_posts 就是我们文章源文件的目录。服务运行时,会把markdown 文件转为 html 文件。
最后,原始的Jekyll 工程需要做些修改,才能适用于github-pages。操作参考步骤9-10。creating-a-github-pages-site-with-jekyll
# Run. 浏览器访问:http://localhost:4000
bundle install
bundle exec jekyll serve
必须命名为 <user>.github.io
存储库必须是公共的。如果改为 private, Github Pages 访问404。
GitHub Pages 站点是使用 GitHub Actions 工作流生成和部署的。工作流是默认的,不用做任何修改。
可以通过查询 workflow run history 和日志来排查问题
You’ll find this post in your _posts
directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve
, which launches a web server and auto-regenerates your site when a file is updated.
Jekyll requires blog post files to be named according to the following format:
YEAR-MONTH-DAY-title.MARKUP
Where YEAR
is a four-digit number, MONTH
and DAY
are both two-digit numbers, and MARKUP
is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.
Jekyll also offers powerful support for code snippets:
Check out the Jekyll docs for more info on how to get the most out of Jekyll. File all bugs/feature requests at Jekyll’s GitHub repo. If you have questions, you can ask them on Jekyll Talk.