10 issues encountered during the 2015 work: 1-10

Source: Internet
Author: User

1.NullPointerException.
Content classification has dirty data, resulting in error, you need to determine whether the variable is null.
View content, ID is not legal, did not find this content, need to determine whether there is a value, if NULL, jump to 404 page.


2.PDF Download "Illegal" file name appears.
Linux and Windows, there are certain restrictions on file names, which prohibit several characters from appearing in filenames.
In the implementation of the PDF download, I was the title of the article as a filename, title appeared "illegal characters", such as
"A first-tier city of it white-collar living costs 30,000/year. There is an illegal character"/"in PDF.


In Apache Common Filenameutils did not find the filter method, you write a simple filter method, "/" and other characters to replace "".
Java Regular replacement: Filteredname = Name.replaceall ("[/<>|\"?:] "," "). ReplaceAll (" \\\\ "," ");


3.log4j Output information is not comprehensive.
<param name= "Conversionpattern"
Value= "[%d{yyyy-mm-dd hh:mm:ss\}%-5p] [%t]%l-%x{loginuser}%x{userip}%m%n"/>

The full name of the class to which the%c output belongs can be modified to%d{num}, the dimension that the Num class name outputs (such as: "Org.apache.elathen.ClassName",%c{2} will output elathen. ClassName)
%l output Log event location, including the class name, the thread that occurred, the number of lines in the code

%l is more useful than%c, which is a bit longer information.
It is slower to locate the log without knowing the line number.


4. Paging parameters, check, but still not comprehensive enough, unexpectedly appear pagesize null case.
It seems that the consideration is not well-rounded.
Previously, the focus was on checking if pagesize and PageNo were positive, as well as range.

5. The search parameter is empty.
The backend does a null check, but the front end does not enter "search term", also carries on the back-end query, compares the waste.
The front end adds JS check to reduce unnecessary request processing on the server side.

6. During the deployment of a Web site, there are frequent code conflict issues.
For the first deployment, there are several directories, such as Article,article.service.
But the second deployment, code refactoring, only article a directory, this time directly copy-paste replacement to deploy,
Article.service This directory still exists and may cause a class file, such as Searchservice, to exist in 2.
Cause spring @Autowired error.


This question suggests that the previous code needs to be emptied prior to deployment. Of course, it's a good idea to make a full backup first.


when the 7.Maven project was packaged, the XML file was not packaged and ignored directly.
Until January 8, 2015, there was no manual configuration of MAVEN to package XML, and this time there was a problem, and a few more configurations were added to the pom.xml.
<build>
<plugins>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>


8.p2p trial operation.
Many platforms have a "pilot" phase, before "officially on line." is a transitional phase, if there is a problem, timely repair.
Pilot operation phase, the user is generally not too much, the loss will not be too large.


"Trial operation" and the online game "beta" similar.


9. When working with files, it is necessary to check the existence of files.
File File = new file (Log4jxmlpath);
Boolean exist=file.exists ();
Using the Exists method is much more friendly than going to capture java.io.FileNotFoundException.

in 10.java Web projects, the location of log4j.xml and the log output directory of log4j are configurable.
<servlet-name>Log4jInit</servlet-name>
<servlet-class>cn.fansunion.common.web.Log4jInit</servlet-class>
<init-param>
<param-name>log4jOutputPath</param-name>
<param-value>C:/log4j/xiaolei</param-value>
</init-param>
<init-param>
<param-name>log4jXmlPath</param-name>
<param-value>C:/log4j.xml</param-value>
</init-param>
</servlet>
Configure the variable in Web. XML, write the log4j initialization servlet, parse the variable in the servlet, and then manually initialize the log4j.

System.setproperty ("Log4joutputpath", Log4joutputpath);
Domconfigurator.configure (Log4jxmlpath);

It took 1 hours to write the servlet and finish the test.
Detailed custom configurations are no longer shared in this article.


The official website has been operating for some time, looking at the logs of the last 2 months and discovering a lot of problems.
Currently, there are some fixes.
Other problems are one after the other, too many technical details.

10 issues encountered during the 2015 work: 1-10

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.