Skip to content

Instantly share code, notes, and snippets.

Avatar

arganzheng arganzheng

View GitHub Profile
@arganzheng
arganzheng / index.html
Last active Oct 15, 2018
使用bootstrap进行复杂页面布局
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Blog</title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
</head>
<body>
<div class="container">
@arganzheng
arganzheng / sinatra.md
Last active Dec 21, 2015
sinatra arganzheng
View sinatra.md

使用Sintra开发文档系统

安装

ruby && gem

对于windows环境,最简单的方式是下载一个installer,双击运行就可以了。

sinatra

View WebUtils.md

Spring MVC其实提供了一些好用的util类:

import org.springframework.web.util.WebUtils;

Cookie cookie = WebUtils.getCookie(request, "SECURITY_TOKEN");
@arganzheng
arganzheng / nginx-proxy-cache.conf
Last active Dec 20, 2015
我本地的nginx.conf,配合proxifier可以做灰度测试。
View nginx-proxy-cache.conf
worker_processes 1;
error_log logs/error.log;
pid logs/nginx.pid;
events {
# use epoll;
worker_connections 1024;
View spring-interceptor.md

Spring interceptor

配置

<!-- Configures Handler Interceptors --> 
<mvc:interceptors>  
    <!-- This bit of XML will intercept all URLs - which is what you want in a web app -->
    <bean class="me.arganzheng.study.api.container.interceptor.AuthorizationInterceptor" />
@arganzheng
arganzheng / ApiDao.java
Last active Dec 19, 2015
如何autowired sqlMapClient到Dao对象中,解决这个问题`java.lang.IllegalArgumentException: Property 'sqlMapClient' is required`。参考文章: 1. http://edwin.baculsoft.com/2010/08/yet-another-simple-swing-spring-and-ibatis-integration-example/ 2. http://stackoverflow.com/questions/3807707/injecting-derived-property-for-repository-bean-without-autowired-in-super-clas
View ApiDao.java
@Repository
public class ApiDao extends SqlMapClientDaoSupport {
// empty constructor
public ApiDao() {
}
// autowired constructor
// i dont know why, but i cant autowired sqlMapClient directly
// it will cause java.lang.IllegalArgumentException: Property 'sqlMapClient' is required
View XmlFileApiMetadataDao.java
package me.arganzheng.study.metadata.dao;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
import javax.xml.bind.JAXBContext;
View config-log4j-for-ibatis-to-print-sql.md

如何打印ibatis拼凑的动态SQL语句

log4j.logger.java.sql.PreparedStatement=debug
log4j.logger.java.sql.Connection=debug

将打印出Connection和Statement信息:

[DEBUG] 11:48:17 Connection - {conn-100000} Connection
[DEBUG] 11:48:17 Connection - {conn-100000} Preparing Statement:    select api.id   from t_api_metadata_api api,   t_api_metadata_module module   where api.module_id=module.id   and api.source = ?   and api.name = ?       and     api.module_id = ?        and     module.name = ?         
View redirect-with-js-after-some-time.md

JS实现一段时间后自动调转页面

setTimeout(function(){
	window.location.href="./modules.xhtml?source=${source}";
	}, 2000
);
View MappingJsonpHttpMessageConverter.java
package me.arganzheng.study;
import java.io.IOException;
import java.io.PrintStream;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;