自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Json随笔

星星,不过是颗足够遥远的石头

  • 博客(85)
  • 收藏
  • 关注

原创 MySQL不支持中文、将编码修改为utf-8,仍不支持中文问题解决方案

今天在向MySQL插入中文字符的时候,发现有警告,插入的字符全是问号。上网查了下,发现是字符编码的问题。。。。完美解决这个问题的方案在是修改mysql的配置文件,ubantu系统默认的mysql文件位置在:/etc/mysql/my.cnf。vim /etc/mysql/my.cnf。然后在[client]下添加: default-character-set=utf8。在[mysqld]下添加:

2016-01-13 12:00:38 7168 5

转载 Spring 拦截器与过滤器

http://blog.csdn.net/chenleixing/article/details/44573495

2015-12-30 10:51:55 423

转载 spring 拦截器

http://haohaoxuexi.iteye.com/blog/1750680 SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理。比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像12306 那样子判断当前时间是否是购票时间。 一、定义Interceptor实现类SpringMVC 中的Inte

2015-12-30 10:47:06 1817

转载 Spring MVC 返回类型为字符串时, 返回中文变成"?"处理

转自:http://www.cnblogs.com/zemliu/p/3497025.html这里使用ResponseBody, 返回值直接是一个字符串, 没有用到jackson, 如果是返回一个Object, 使用jackson转json, 是没有编码问题的这时酒店查询几个字全都变成了问号由于Spring处理返回值为String类型的结果时使用了StringHttpMessageConverter

2015-12-29 18:43:07 1213

原创 Spring MVC过滤器-委派过滤器代理(DelegatingFilterProxy)

org.springframework.web.filter中有一个特殊的类——DelegatingFilterProxy,该类其实并不能说是一个过滤器,它的原型是FilterToBeanProxy,即将Filter作为spring的bean,由spring来管理。配置方式如下:1.配置web.xml方法1:(不要求filer-name与实现javax.servlet.Filter的bean的类名相

2015-12-29 16:01:46 857

原创 Spring 过滤器DelegatingFilterProxy No WebApplicationContext found: no ContextLoaderListener registered?

先说明一下,如果使用Spring 过滤器org.springframework.web.filter.DelegatingFilterProxy的时候出现错误“No WebApplicationContext found: no ContextLoaderListener registered?”的解决方案 出现这个问题,应该不是过滤器本身的问题,而是对web.xml相关内容了解的不够,可以参看:

2015-12-29 15:08:22 56610 5

原创 URL和URI

对于URI的定义是:统一资源标识符; 对于URL的定义是:统一资源定位符。 二者的区别在于,URI表示请求服务器的路径,定义这么一个资源。而URL同时说明要如何访问这个资源URL是URI的子类,即URL都是URI,而URI并不一定都是URL。URL必须是绝对路径,URI可以为相对路径。在Java中,测试如下:程序: public void doFilter(ServletRequest r

2015-12-28 12:00:03 360

原创 Guava Cache缓存

本博客参考自:http://ifeve.com/google-guava-cachesexplained/Guava 的maven dependency:<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>14.0-rc2</version></de

2015-12-23 18:07:24 514

原创 Eclipse 新建maven项目没有.classPath文件/不能创建新的资源文件/不能创建新的java类。。。。

前几天在使用eclipse创建新的maven项目的时候,发现不能创建新的source folder,在创建source folder的时候提示is not a java project。打开项目目录发现,并没有.classPath文件。并且不能创建新的java类。而使用eclipse创建普通java工程的时候,则没有以上的情况。所以,确定应该是maven的问题。解决办法:第一步: 更换稍微低版本的

2015-12-15 14:51:23 6507

原创 二叉树遍历 递归与非递归 Java

程序如下:import java.util.Stack;public class TreeNode { public int val; public TreeNode(int val) { this.val = val; } public TreeNode left; public TreeNode right; public static

2015-09-25 15:31:17 342

转载 TCP/IP协议三次握手与四次握手流程解析

【注】内容转自:http://www.2cto.com/net/201310/251896.htmlTCP/IP协议三次握手与四次握手流程解析一、TCP报文格式 TCP/IP协议的详细信息参看《TCP/IP协议详解》三卷本。下面是TCP报文格式图:图1 TCP报文格式 上图中有几个字段需要重点介绍下: (1)序号:Seq序号,占32位,用来标识从TCP源端向目的端发送的字节流,发起

2015-09-23 17:36:22 461

转载 LeetCode 5 Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.找到一个字符串中最大的回文子字符串程序来自:https

2015-09-12 16:03:35 294

原创 Leetcode 3 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For “

2015-09-12 10:26:47 250

原创 LeetCode 279 PerfectSquares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return

2015-09-11 12:24:23 307

原创 LeetCode 274/275 H-Index Java

H-Index IGiven an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index.According to the definition of h-index on Wikipedia:

2015-09-11 11:14:28 552

原创 LeetCode 278: First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2015-09-10 11:23:51 402

原创 Ugly Number I 和 II LeetCode

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it in

2015-09-01 16:10:17 295

原创 Missing Number Leetcode 268 Java

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run in line

2015-09-01 15:23:40 373

转载 mybatis 中#与$的区别

MyBatis/Ibatis中#和$的区别1.# 将传入的数据都当成一个字符串,会对自动传入的数据加一个双引号。如:order by #user_id#,如果传入的值是111,那么解析成sql时的值为order by "111", 如果传入的值是id,则解析成的sql为order by "id". 2.$ 将传入的数据直接显示生成在sql中。如:order by$use

2015-08-28 14:22:45 230

转载 杨氏矩阵第K小值/两个数组元素之和最小值

最近在面试中被问到一道算法题目: 给定两个有序数组A[]和B[],求A[i]+B[j]的第k小的。不幸当场没给出答案。。。回来查了一下,其实这个题目还可以转换为杨氏矩阵中第k小的值。不知道什么是杨氏矩阵的,可以自行百度。或者简单理解为一个每行每列都是递增的矩阵。这道题目可以用二分法来解,具体算法如下: public int KthSum(int[] A, int[] B,int k){

2015-08-12 10:11:36 587

原创 Leetcode 238 Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For e

2015-08-06 19:56:37 184

原创 LeetCode 239 Sliding Window Maximum

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window mo

2015-08-06 19:16:22 386

原创 LeetCode:242 Valid Anagram Java

Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note: You may assume the s

2015-08-05 21:07:08 1822

原创 Java Thread.UncaughtExceptionHandler

如果在java中定义了如下的类,希望在多线程环境下,捕获异常 static class myRun implements Runnable { @Override public void run() { System.out.println("myRun.run()"); throw new RuntimeExce

2015-08-05 16:52:58 375

原创 Delete Node in a Linked List Java LeetCode

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t

2015-07-31 12:21:20 1142

原创 Lowest Common Ancestor of a Binary Search Tree Java LeetCode

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two

2015-07-31 11:06:52 245

转载 Redis 和 Jedis

一直想整理一些redis的资料,今天终于有开始了~1、 什么是Redis (以下内容参考自百度百科:http://baike.baidu.com/link?url=_daPcmtbGPr4cSc8J-pN_YXFpXzPdQ83iTGHj7QmtZc0OUDFA4InvaYbIBJlBKjGugLwDJeM3iwAJWlCh-OgCK)redis是一个key-value存储系统。和Memcache

2015-07-29 14:43:24 553

转载 Java Error和Exception

Error类和Exception类都继承自Throwable类。Error的继承关系:Exception的继承关系:二者的不同之处:Exception:1.可以是可被控制(checked) 或不可控制的(unchecked)。2.表示一个由程序员导致的错误。3.应该在应用程序级被处理。Error:1.总是不可控制的(unchecked)。2.经常用来用于表示系统错误或低层资源的错误。3.如何可能的话

2015-07-20 19:34:41 200

原创 Java list foreach 修改元素

在使用foreach遍历list时候,可以修改元素,但是不能替换list中的元素,示例如下: List<O> oList = new ArrayList<O>(); for (int i = 0; i < 10; i++) { oList.add(new O()); } for (O o : oList) {

2015-07-20 16:15:38 9489

原创 Spring bean加载顺序 depends-on

今天遇到了一个问题。 在Spring工程中,Bean1在init()的时候用到了Bean2的static属性,所以需要Bean2的初始化必须在Bean1()之前。查了一下,这个时候需要用depend-on,在此mark一下。depend-on用来表示一个Bean的实例化依靠另一个Bean先实例化。如果在一个bean A上定义了depend-on B那么就表示:A 实例化前先实例化 B。

2015-07-20 10:48:48 2136

原创 Leetcode 2 Add Two Numbers Java

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke

2015-07-06 16:01:11 181

转载 LeetCode 1 Two sum Java

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where in

2015-07-06 15:46:00 213

原创 Power of Two LeetCode Java

Given an integer, write a function to determine if it is a power of two.一行解决战斗:return n > 0 && (n & (n - 1)) == 0;

2015-07-06 11:52:07 493

翻译 Contains Duplicate III

本博文参考自:https://leetcode.com/discuss/38206/ac-o-n-solution-in-java-using-buckets-with-explanationGiven an array of integers, find out whether there are two distinct indices i and j in the array such tha

2015-06-30 19:50:35 312

转载 The Skyline Problem Leetcode Java

public class Solution { class KeyPoint { public int key; public int height; public KeyPoint next = null; public KeyPoint(int key, int height) { this.key = k

2015-06-30 17:46:53 377

原创 Word Search II Leetcode Java

Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizont

2015-06-29 17:06:47 499

原创 Majority Element 和 Majority Element II LeetCode Java

Majority Element Total Accepted: 44517 Total Submissions: 127008 My Submissions Question Solution Given an array of size n, find the majority element. The majority element is the element that appears

2015-06-29 15:45:33 425

转载 Course Schedule I II LeetCode Java

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:

2015-06-27 15:58:09 396

翻译 House Robber II LeetCode Java

本博客参考自:https://leetcode.com/discuss/36544/simple-ac-solution-in-java-in-o-n-with-explanationNote: This is an extension of House Robber.After robbing those houses on that street, the thief has found him

2015-06-24 16:10:35 313

原创 Shortest Palindrome Leetcode Java

Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.For example:G

2015-06-24 14:27:50 312

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除