The most important difference between MongoDB and relational database is the asymmetric, weak transaction of the table structure, MongoDB sacrifices the transaction to exchange for faster access speed, some people say that MongoDB is too greedy for memory, in fact, it is not necessarily, Take windows as an example it will default on the number of 1 million available connections, grab the memory to go through the practice to know, with a 6-core CPU For example MongoDB use of memory is not the basic number. Although there is a great difference in the drive to provide this MongoDB drive. If the 2.10 version of the drive connection database can also use MONGO but behind the driver is not MONGO, instead of the mongoclient. Although MongoDB and relational database although there are differences, but the processing of resources are the same, below to share my development process encountered problems.
1 Considerations for displaying JSON data using Freemarker
Struts2 is the first choice for many companies, but there are many limitations to using struts2, such as the inability to iterate through JSON. Even using velocity can get JSON data. The only choice is only freemarker, but the use of Freemarker is also a bit of a disadvantage that is a single mongodb data if it is a null type, the page will be an error, the only solution to this situation is to add data when the validation of data validity
2 Considerations for using Freemarker with JSP
Although the JSP function is powerful, but does not support the Freemarker, in the JSP also cannot use the Freemarker label, sometimes the JSP all replaces with the FTL also is unrealistic, in this case can only be the Freemarker TLD introduced in the page to use < Fm:template></fm:template>, wrap up the Freemarker code.
3 Freemarker precautions for using struts tags
Freemarker also can not directly support struts tags, but in response to this situation online also provides a solution, if necessary can directly Baidu
4 MongoDB Considerations
When using the program and MongoDB interaction, many netizens give advice really can be said to be fraught, such as "using MongoDB can not shut down the database connection" This is really a big mistake, although have not seen the Windows version of the MongoDB connection will be used to the end of the kind, But the Linux version if the number of connections ran out, the database will be hung up, this problem is particularly serious, the data lost does not say that it will cause great economic losses. The Java program suggests that you write a tool class that gets the connection and closes the connection, then writes an interface and declares a common method, and then writes the implementation class and the Proxy action class. Connection creation, shutdown is done by the Agent action class, and then a unified method call is written for a factory operation class, and here's a suggestion for a programmer who likes to use spring: don't integrate MongoDB and spring, it really doesn't do much good.
Considerations for using MongoDB and Freemarker in Java