Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View arganzheng's full-sized avatar

arganzheng arganzheng

View GitHub Profile
@arganzheng
arganzheng / index.html
Last active October 15, 2018 03:05
使用bootstrap进行复杂页面布局
<!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 December 21, 2015 02:59
sinatra arganzheng

使用Sintra开发文档系统

安装

ruby && gem

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

sinatra

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

import org.springframework.web.util.WebUtils;

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

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 December 19, 2015 23:59
如何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
@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
@arganzheng
arganzheng / XmlFileApiMetadataDao.java
Last active December 19, 2015 23:59
JAXB序列化
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;

如何打印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 = ?

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

setTimeout(function(){
	window.location.href="./modules.xhtml?source=${source}";
	}, 2000
);
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;