Download file in Spring MVC example

Each download method is transfer data from server to client. Use Spring MVC is the same way to do that. The first thing is find the downloaded file. The second thing is read it and transfers it. In this blog I will show you how to use Spring MVC download file. For quickly start I use Spring Boot. The code also works fine in Spring.

Spring Boot change default port

The default port in Spring Boot of web application is 8080. There are two ways to change this default port. The first way is to change file. The second way is to add VM option when start your web application.

Spring Boot get resource file example

I have written the blog Read values from properties file in Spring to show how to get values from properties file. In this blog I will show you how to get resource file (not only properties file) in Spring. As using maven build the project all resource file are put in resources folder.

Avoiding null check in java

There is lots of ugly null checking in my project. For example if you want print out the address of user. ORM (Hibernate or MyBatis) will help you query this user with address info. You may get a user entity like following.

MyBatis pagination example

In this blog I will show you how to get paged query result with MyBatis plugin pagehelper. If you are interested in it see the link for more detail. I use MyBatis generator plugin to generate mapper and xml file. If you do not know how to use it click here

MyBatis generator return id after insert

In this blog I will show you how to generate mapper that can return auto increase id after inserting. If you do not know how to use MyBatis generator you can click here. You can also use maven plugin or other tools to generate mapper xml file and model class.

Store UUID in MySql

There are two ways to store UUID in MySQL. The one is save it as varchar(36), the other is save is as varbinary(16). The first way is easy for developer, just set UUID string in field of entity and insert it into database. But the second way can save disk space and quick.

Java get element in set

There are a lot of ways to get one element from set. I do not recommend you to do this. If you need get one of them use List instead.

JQuery append() prepend() after() and before()

There are some methods in JQuery change the content of page. Different methods add the element to different position. In this blog I will show you the different of them. You can also save the following code as html file and run it. Click the different button can add the different element to the page.

Search string in linux directory

grep command can help you search specific string in file. Learn basic use of it click here. grep is very powerful. It can help us to search specific string in a Linux directory. For example, we have two files in tmp directory.

Ajax post serialized form to SpringMVC

You can submit a form directly or use Ajax to submit data.In this page I will show you how to use Ajax post serialized form data to SpringMVC. In this way your application will be more friendly.

Front End tutorial

There are lots of technologies in Front End. In this tutorial I will show you how to use common page front-end technology. Hope these blogs help you.

Ajax post json xml to SpringMVC

We can use json and xml to store complex data in our application. In this post I will show you how to use Ajax post xml and json to springMVC. For quickly starting I use Spring Boot in my example. The code also works in SpringMVC.

Java convert object xml example

There are many ways to convert object to xml. In this post I will show you how to use XStream to convert object to xml. In order to use XStream add maven dependency like following.

Linux find command examples

find is a very useful command when you want "find" something in Linux. In the page I will learn the basic use of this command with you. For the detail of find you can learn from manual(type man find in command line).