2015 problems encountered in the work: 71-80,tomcat-redis-floating point-https

Source: Internet
Author: User
Tags pkcs12

71.Tomcat Access project with "project name".
The simplest way to do this is to deploy the project to the "root" directory, which, according to the boss, will be placed on each of the 1 Tomcat's root projects.
However, our actual project has encountered some problems.
Front project, front-end system
Backend project, backend management system
CMS with Static resources, front-end System 2


Due to the picture and other resources, the existence of a relative path, but also need to let front and backend have access to the picture, we finally decided to put the CMS in the root directory of Tomcat.
After the project is published, the access path to the Front project is: Http://a.com/Front.
This path is really pit, http://a.com, cannot be accessed directly, we added a index.jsp under CMS system, redirected to Http://a.com/Front.


This is really bad, but for the time being.


Other considerations:
Multiple customer projects may be deployed on a well-configured server.
So, from a simplified deployment point of view, a customer with only one tomcat, only one root, this is a tangled place.


If it's me:
The first method, a client with 2 Tomcat, is management a little more troublesome.
The second method, CMS system and front system merge into one, small company multiple projects put together, more simple development and maintenance.
The third method, a customer with 1 configuration of the lower server, open 2 tomcat, or even multiple, nginx with good.


72. The floating-point number is multiplied, the yuan is transferred, and the sub is converted into yuan.
Money internal with double, sometimes right, sometimes wrong, unstable
Double A =5.1d;
Money m = new money (a);
System.out.println (m);


509.99999999999994, Straight hole.
Double d = 5.10*100;
System.out.println (d);


Method One: Use the BigDecimal Setscale method to set the "precision" and "rounding mode".
BigDecimal bd = new BigDecimal (d). Setscale (3,BIGDECIMAL.ROUND_UP);
System.out.println (Bd.longvalue ());
System.out.println (Bd.doublevalue ());


Method Two:
public static double Mul (double v1, double v2) {
BigDecimal B1 = new BigDecimal (double.tostring (v1));
BigDecimal b2 = new BigDecimal (double.tostring (v2));
Return b1.multiply (B2). Doublevalue ();
}


Method Three: Boss more inclined, "Yuan to divide" own realization, but, does not fundamentally solve "the ordinary double multiplication problem", only solves "the yuan to divide" this special specific problem.
Input:
Type: Double
Typical value: 5,5.0,5.10,5.09,5.011


1th step: Convert to a unified format, 5.00, 2 digits after the decimal point, after the 3rd position, directly out.
2nd Step: Extract integer part Intpart and fractional part Doublepart.
3rd Step: Intpart*100+doublepart.


Want to explore the difference between bigdecimal.multiply and method three, but the source is not read.


Resources:
JDK1.6 API Documentation
Http://www.csdn123.com/html/blogs/20130818/55035.htm
Ray powder-Love Confucius Meng


73. Where the template or view page is stored.
The template file under the WebContent directory, which can be accessed directly through the URL, is likely to leak the source code of the View section.
From a security point of view, it is better to put it in the Web-inf directory.


The FTL template should not be placed in the root directory of the webcontent.
The outside world can be directly accessed, very dangerous,
JSP is also relatively safe, the default will be executed, will not directly leak source code.

74.Freemarker variables are best judged if they exist.
< #if role?exists && role== "admin" >
If the role does not exist, it may cause an error and hinder the execution of the subsequent Freemarker code.
It's cumbersome to see if a variable is null and exists.

75.Tomcat Configure HTTPS.
Two-way certificate reference is, Baidu experience on the
Http://jingyan.baidu.com/article/a948d6515d3e850a2dcd2ee6.html
A practical command:
Keytool-genkey-v-alias tomcat-keyalg rsa-keystore c:/p2p/tomcat.keystore-validity 365

Keytool-genkey-v-alias mykey-keyalg rsa-storetype pkcs12-keystore c:/p2p/mykey.p12

Keytool-export-alias mykey-keystore c:/p2p/mykey.p12-storetype pkcs12-storepass 123456-rfc-file c:/p2p/mykey.cer

Keytool-import-v-file C:/p2p/mykey.cer-keystore C:/p2p/tomcat.keystore

Keytool-list-keystore C:/p2p/tomcat.keystore

Keytool-keystore C:/p2p/tomcat.keystore-export-alias Tomcat-file C:/p2p/tomcat.cer

<connector port= "8443" protocol= "Org.apache.coyote.http11.Http11NioProtocol"
Sslenabled= "true" maxthreads= "scheme=" "https"
Secure= "true" Clientauth= "true" sslprotocol= "TLS"
Keystorefile= "C:/p2p/tomcat.keystore" keystorepass= "123456"
Truststorefile= "C:/p2p/tomcat.keystore" truststorepass= "123456"/>


One-way certificate, have not tried, found an article looks good
http://forchenyun.iteye.com/blog/473776


On the Javaeye, a certificate configuration tutorial with one-way and two-way is also found.
http://juncao2011.iteye.com/blog/973988

It is said that an agency issued 1 HTTPS certificates, a yearly fee of 7000 yuan, eat people ah.


76. Connect the remote Redis-server via the local console.
CD/D E:\Mongodb-Redis-Nginx\redis_win\redisbin_x64
Redis-cli-h 120.90.56.110-p 6379


If Redis on the server does not have a password set, it can be accessed successfully by using the above command.


77.VIM Find command.
Want to find the password configuration of the note in Redis, hundreds of lines, it is too lazy line down.
It seems that it is still necessary to learn the "find command".
Method: In command mode, press '/', then enter the character to find, enter. and/The difference is that one is looking forward (down), one backwards (up).
Reference: Http://zhidao.baidu.com/link?url=4rSOqYZEPYH9h_B8MRPyVSC9IuTiJGlaVfJYgGU1ir1mXvr_ Tu-cfo0aj5oz8tn6jkqndqkfh5ei0_dgxif1h_


78. Set the Redis password.
The password configuration was found on line No. 348 through/requirepass.
348 # Requirepass Foobared


Put the password this relatively common configuration, put in the end is too unscientific, manually in the first few lines of redis.conf, add password configuration:
Requirepass Xiaolei
Redis-cli-h 120.90.56.110-p 6379-a Xiaolei
Reference: http://www.iteye.com/topic/1124400


the location of the 79.hosts file.
Linux:/etc/hosts
Windows:c:\windows\system32\drivers\etc\hosts


Directly modifying the Hosts file on Windows may be blocked by security software such as "QQ computer steward", as there is a "security risk" to directly modify the Hosts file.


80. The database field name and SQL Map Java attribute name are converted to lowercase.
The original is uppercase, want to change to lowercase, look comfortable.
Mysql-front, did not bring the big write "abc" to convert to lowercase "ABC" tool, had to manually change.
Java field name in MyBatis, manual change, too slow point, you can use Eclipse's shortcut key "Ctrl+shift+y", "uppercase to lowercase".
"Ctrl+shift+x", "lowercase to uppercase", but unfortunately with the QQ Pinyin input Method of the screen shortcut keys conflict, you can manually change the screen shortcut keys QQ.

2015 problems encountered in the work: 71-80,tomcat-redis-floating point-https

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.