代码改变世界

随笔档案-2014年04月

使用注解属性绑定

2014-04-29 19:28 by Rollen Holt, 4722 阅读, 收藏, 编辑
摘要: 大家应该知道在Spring中有一个注解@Value,他可以帮助我们来讲Spring加载的配置文件(*.perperties)文件中的信息自动的注入到我们的非静态属性中的。一般情况下我们会这样使用:1. 首先在Spring的配置文件中加载属性文件:然后在Java代码中使用@Value注解就可以注入值... 阅读全文

RESTful的理解

2014-04-27 01:16 by Rollen Holt, 29110 阅读, 收藏, 编辑
摘要: REST(Representational State Transfer ),有中文翻译为"具象状态传输"(也有:"代表性状态传输")。是由 Roy Thomas Fielding博士 在2000年就读加州大学欧文分校期间在学术论文中提出的一个术语。他首次系统全面地阐述了REST的架构风格和设计思想... 阅读全文

Spring 文件上传功能

2014-04-26 23:18 by Rollen Holt, 47314 阅读, 收藏, 编辑
摘要: 本篇文章,我们要来做一个Spring的文件上传功能:1. 创建一个Maven的web工程,然后配置pom.xml文件,增加依赖: org.springframework.boot spring-boot-starter-web 1.0... 阅读全文

使用Spring Boot来加速Java web项目的开发

2014-04-26 22:57 by Rollen Holt, 121674 阅读, 收藏, 编辑
摘要: 我想,现在企业级的Java web项目应该或多或少都会使用到Spring框架的。回首我们以前使用Spring框架的时候,我们需要首先在(如果你使用Maven的话)pom文件中增加对相关的的依赖(使用gradle来构建的话基本也一样)然后新建Spring相关的xml文件,而且往往那些xml文件还不会少... 阅读全文

select 1 from dual 中的1表示的含义

2014-04-26 15:48 by Rollen Holt, 8320 阅读, 收藏, 编辑
摘要: select 1 from dual 在这条sql语句中的1代表什么意思?查出来是个什么结果?其实:select 1 from table;select anycol(目的表集合中的任意一行) from table; -- (目的表集合中的任意一行)select * from table 上... 阅读全文

提高SQL的查询效率

2014-04-26 15:39 by Rollen Holt, 1528 阅读, 收藏, 编辑
摘要: 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: select id from t where num is null 可以... 阅读全文

资料推荐--Google Java编码规范

2014-04-26 00:11 by Rollen Holt, 32419 阅读, 收藏, 编辑
摘要: 之前已经推荐过Google的Java编码规范英文版了:http://google-styleguide.googlecode.com/svn/trunk/javaguide.html虽然这篇文章的英文很简单,但是最近发现有人翻译了这篇文章,所以专门写一篇文章推荐一下:http://hawstein.... 阅读全文

书籍推荐-《高性能网站建设指南》

2014-04-16 22:57 by Rollen Holt, 1104 阅读, 收藏, 编辑
摘要: 《高性能网站建设指南》这本书很不错,这几天刚刚在亚马逊上淘到的。书里面的内容不算太多,而且书籍也不算太厚,但是内容真心不错。推荐给大家。另外推荐@Fenng的一篇文章:http://dbanotes.net/web/high_performance_web_site.html 阅读全文

Google Guava vs Apache Commons for Argument Validation

2014-04-10 00:07 by Rollen Holt, 5727 阅读, 收藏, 编辑
摘要: It is an established good practice to validate method arguments at the beginning of the method body. For example you could check that the passed value is not negative before doing some calculation:123456public int doSomeCalculation(int value) {if (value = 0, "negative value");More recently 阅读全文

Fluent interface

2014-04-09 23:39 by Rollen Holt, 1098 阅读, 收藏, 编辑
摘要: Insoftware engineering, afluent interface(as first coined byEric EvansandMartin Fowler) is an implementation of anobject orientedAPI that aims to provide for more readable code.A fluent interface is normally implemented by usingmethod cascading(concretelymethod chaining) to relay the instruction con 阅读全文