JQuery loop array example

In this page I will show you how to loop an array by using JQuery and Javascript. I recommend using JQuery to loop an array. Examples are here.

Change character set in MySQL

Recently I met Chinese garbled(中文乱码) problem in MySQL. Solve this problem by changing the character. In this page I will show you how to change character in MySQL. Before changing it we need to know the support character sets in MySQL.

Update null or not exist field in MongoDB

Use db.collection.update to update the document. Do not know how to update document you can click Update document in MongoDB. In this page I will show you how to update document which field is null or not exists.

Count document in MongoDB

Use db.collection.count() to count the number of documents. You can add a query filter to count the specific documents. Examples are here.

Remove the last character in Java

StringUtils in apache-common-lang3 framework is an useful class. You can use removeEnd to remove the last character or characters. If you want remove the character and ignore the case use removeEndIngoreCase instead.

Update document in MongoDB

We use db.collection.update() to update the document. Since version 3.2 you can use db.collection.updateOne() ,db.collection.updateMany() or db.collection.replaceOne() to update document or documents. Click here for more detail. In this page I will show you simple examples.

Encoding(garbled) problem in SpringMVC tomcat

When I use SpringMVC and tomcat to develop the project I often meet garbled problem. In this page I will show you the right way to use them. The most important thing is making the "input" and "output" encoding same.

Use IDEA Mybatis plugin generate mapper files

Mybatis is a light weight Java persistence framework(compared with Hibernate). You have to write a lot of mapper xml files and mapper interfaces. These things are duplicate works, we can generate them by IDEA Mybatis plugin. In this page I will show you how to use this plugin to generate xml mapper file and mapper interface.

Spring boot scheduled tasks example

In this page I will show you how to use scheduling tasks with Spring Boot. As we all known there is no config file in Spring Boot. We use annotations to config scheduling tasks. This example also works well in Spring.

Count the number of output lines in Linux

If the output or a text file is not too long we can know how many lines. But sometimes the output is to long to show them in one screen. At this point you need wc command to count the numbers of output lines. For example there are many log files like following.

Spring MongoTemplate example

MongoTemplate can help you CURD documents in MongoDB easily. In this page I will show you how to use it. I would recommend you to learn Mongo tutorial first, if you are unfamiliar with commends in MongoDB. For quick start I use Spring Boot to test MongoTemplate.

Spring boot parse POST json example

You can post a form to server and parse the data. Json is a lightweight data format, it's better to post json when your data is complex. In the page I will show you how to parse json data in Spring Boot. You can use Postman or other REST clients to send a POST request. I prefer to use REST Client in Intellij IDEA. Click Use Intellij IDEA REST Client POST json for more detail.

Use Intellij IDEA REST Client POST json

If you develop RESTful Web Service you can use REST Client to test it. The tool can help you submitting a request. It is in Tools | Test RESTful Web Service. After opening the tool you can choose the HTTP method. This tool support common methods(POST,GET,DELETE etc.). In this page I will show you how to use it POST json.

Common Content-Type when POST data

There are 3 common Content-Type when POST data to server. We use Content-Type to tell server the type of data. This page will list 3 common Content-Type in POST.

Difference between save and insert in MongoDB

Insert data into MongoDB is very easy. In this page I will tell you the difference between save method and insert method in MongoDB. If you don't know how to insert data into MongoDB you can see this blog(Insert data in MongoDB). To put it simply, save method will call insert or update method. It is depends on the data you saved contain the _id or not. If the data you saved contain the _id save method will call update method. If not it will call insert method. Examples are here.