Skip to content

Instantly share code, notes, and snippets.

View fuzhengwei's full-sized avatar
💬
微信公众号:bugstack虫洞栈

小傅哥 fuzhengwei

💬
微信公众号:bugstack虫洞栈
View GitHub Profile
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Leon
*
* @param <T>
*/
public class TestDao<T> {
@fuzhengwei
fuzhengwei / CustomDateSerializer.java
Created September 21, 2014 12:35
SpringMVC返回JSON数据时日期格式化问题
package com.micmiu.demo.web.v1.utils;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
@fuzhengwei
fuzhengwei / EmpController.java
Created September 21, 2014 12:16
springmvc + spring + mybatis + easyui 在这一套应用中,easyui界面的json特殊格式,要用springmvc返回。
/**
* 返回json格式为:
* {"total":"2","rows":[{"id":"142318","firstname":"kkk","lastname":"Popoviceww","phone":"l","email":"dfgd@te.com"},{"id":"142322","firstname":"Hello","lastname":"there","phone":"","email":""}]}
*/
@RequestMapping("doGetEmpList")
@ResponseBody
public Map<String, Object> doGetEmpList(){
List<DrdgEmp> modelList = drdgEmpService.selectModelList();
//获得的list集合装填到map集合
@fuzhengwei
fuzhengwei / XiaoFuNumberGetOne
Created September 21, 2014 07:03
给出一个整数,计算从0到这个整数(包含这个整数)1出现的次数 例如,给出整数:13 -》 0,1,2,3,4,5,6,7,8,9,10,11,12,13 数字1出现了7次,返回6。如果普通的写出来这个函数很随意, 挑战在于-》不要遍历所有的数 (能计算到2千万,计算机1秒内完成计算)看你是否可以做出来?
public class XiaoFuNumberGetOne {
/**
* @param args
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num = 112,saveNum = 1,countNum = 0,lastNum=0,numCopy = num;
while(num!=0)
@fuzhengwei
fuzhengwei / 常用json解析
Created September 20, 2014 11:39
json解析方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>json</title>
<script language="javascript" type="text/javascript">
window.onload = function(){
// 遍历数组对象
@fuzhengwei
fuzhengwei / java基本反射方法-TestReflect.java
Last active August 29, 2015 14:06
java反射基本的方法使用,所有的框架开发都来不开反射技术。
package com.drdg.test;
import java.lang.reflect.Method;
public class TestReflect {
public static void main(String[] args) throws Exception {
System.out.println("获取类下的所有方法:\r\n");
/**
@fuzhengwei
fuzhengwei / Oracle分页语句
Last active August 29, 2015 14:06
oracle中rowid高速分页解析
--rowid分页,第一步
select rowid rid,sal from emp order by sal desc;
--rowid分页,第二步
select rownum rn,rid from(select rowid rid,sal from emp order by sal desc) where rownum<10;
--rowid分页,第三步
select rid from(select rownum rn,rid from(select rowid rid,sal from emp order by sal desc) where rownum<10) where rn>5;
--rowid分页,第四步
select * from emp where rowid in(select rid from(select rownum rn,rid from(select rowid rid,sal from emp order by sal desc) where rownum<10) where rn>5);
****************************************************