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.

Create and drop index in MongoDB

Using db.collection.createIndex(keys, options) to create index for a field. If you want create an ascending index on a filed you need specify a value of 1; for descending index use -1. Examples are here.

Spring MongoRepository example

In this page I will show you how to use MongoRepository insert, delete, update and query document. I assume you have installed MongoDB in your computer. If you don't know how to work with MongoDB you can learn basic methods from MongoDB tutorial. MongoRepository is a interface which can help you CRUD document in MongoDB.

Delete document in MongoDB

Use db.collection.remove() method to delete document in MongoDB. You can define a query to make it delete documents match query. How to define a query click Query document in MongoDB. If you want remove all documents of this collection just use empty query to match all documents. MongoDB will delete all document of this collection.

Query document in MongoDB

In MongoDB db.collection.find() method query documents from the collection. If there is no param in it or passing empty param like this db.collection.find({}) will get all documents in this collection. It is like using select * from table_name in structural database.

Format query result in MongoDB

The default result of querying document in MongoDB is not formatted. But if you query one document by using db.collection.findOne() the result is formatted. Is there any way to format the result of db.collection.find()? Yes, use pretty() append db.collection.find(). Examples are here.

Insert data in MongoDB

We need create table before inserting data into structure database(Mysql, PostgreSQL, Oracle etc.). It is no need to create collection for using MongoDB. The db.collection.insert() method adds new document into database. MongoDB will create collection when it not exist. You can also create collection manually then insert document.

Google "Pure spam" problem

Last week I found my site disappear from Google search result. I tried search "site:www.henryxi.com" but nothing there. A day later I received the message from Google Search Console. To my surprise, Google prevented my site because "Pure spam". The whole message is here

MongoDB tutorial

MongoDB is one kind of document-oriented NoSQL database. Open-source, cross-platform and free are the reasons large numbers of development team choose it. In this tutorial I will show you how to use it step by step.

Drop database in MongoDB

Use db.dropDatabase() to delete the current selected database. If no database selected this command will delete the default database test. Before deleting you need show all database. Delete a database command like following.

Display PDF in Spring example

In this tutorial I will show you how to display and download pdf file in Spring(Spring MVC). For quick beginning we use Spring Boot, and for displaying pdf we use jsp as view.(How to use jsp in Spring Boot, click Spring Boot JSP examples).

Javascript timestamp to date format

It is easy to use SimpleDateFormat format date in Java. There is no method in Javascript to format date directly. When we want format date in javascript we have to use Date method to get Day, Month, Year and combine them together manually.