2015 technical problems encountered in entrepreneurship: 1-10 (garbled-springmvc-jquery-json, etc.)

Source: Internet
Author: User

1. database table name refactoring.
Previously affected by programs such as PHP, database table names like to use the name of the database as a prefix, such as "P2p_account".   After a lot of practice, it is not necessary to find out the Java program basically.      So, starting today, the database indicates that no extra prefixes are added.   Java's DAO and MyBatis XML, used a lot of database table names, I am certainly not stupid, think of Eclipse's replace replacement function.   Replace "P2p_" with "".      Before replacing, random sampling, select several files to see if there is no "manslaughter" that has not yet been found.      MySQL database table name, also want to lead to SQL file, and then the same direct replacement, and later found no, recently imported IP library, there are dozens of MB, or manually rename it anyway.   A similar problem, before manually converting the "uppercase" in the MyBatis into a "lowercase" that looks more pleasing to the eye, manually changing it, later thanks to the boss reminder, using the Eclipse shortcut key, "Ctrl+shift+y". In the future, the brain should be activated to avoid such menial work. 2.properties garbled problem. By default, the. properties file is iso-8859-1 encoded.   Input Chinese, either garbled, or by eclipse into the corresponding UTF-8 characters, and then normal display.   Now there is a problem, want to add Chinese annotation in proerties, "#这是个路径", where "this is the path" will be turned into "#aaaa" this code.      The problem is that the "#aaaa" in the note is not automatically translated to "Chinese" under Eclipse, but not annotated.      In order to solve this problem, think is, ". Properties" Manually set UTF-8 encoding save, but, also can not be directly in Chinese, Chinese variables a= Hello, will not be normal parsing.   We want to: #a你好 a= #aaaa #aaa This is a bad thing, UTF-8 code, eclipse will not automatically convert the input in Chinese, the "#aaaa" format.      You have to do it manually, using the tool that comes with the JDK. In short, there is no good way, only "to maintain the status quo".
Chinese is always a long-standing problem. Who let, originally design the software standard is not the countrymen. 3.SpringMVC file path. P2p.backend_page=e:\gitrepository\backend-system <mvc:resources mapping= "/tpl/**" location= "file:${p2p.backend  _page}/tpl/"/> The file path of this place, is not correct, there is a problem. "P2p.backend_page=e:/gitrepository/backend-system", this is the right.
4.SpringMVC GET request. A. Configuring a monitoring <listener> <listener-class> org.springframework.web.context.request.Re in Web. xml Questcontextlistener </listener-class> </listener> B. Later in the program you can use HttpServletRequest request = (Ser vletrequestattributes) Requestcontextholder.getrequestattributes ()). Getrequest ();
This method, which I need, is convenient for getting the request in the context of the tool class. For example, logging the operation log, obtaining the same attributes as IP and referer from request, can be written in 1 common methods.
Reference: http://yingzhuo.iteye.com/blog/2023989,http://www.cnblogs.com/xusir/p/4135419.html
a big hole in 5.Mybatis. Problem: MyBatis will remove the last if in, SQL becomes "UPDATE p2p_user set paypwd=?" Uptime=now () ", resulting in a SQL syntax error. <update id= "Update" parametertype= "User" >UPDATE P2p_user<set><if test= "Umobile!=null" >Umobile = #{umobile},</if><if test= "Paypwd! = null" >Paypwd = #{paypwd},</if></set>Uptime = Now ()WHERE uid = #{uid}</update>
No problem: If you must modify the Uptime field, use test= "true" to avoid the above problem.<update id= "Update" parametertype= "User" >UPDATE P2p_user<set><if test= "Umobile!=null" >Umobile = #{umobile},</if><if test= "Paypwd! = null" >Paypwd = #{paypwd},</if><if test= "true" >uptime = Now () </if></set>WHERE uid = #{uid}</update> 6.SpringMVC URL Matching question, whether with slash/. @Controller @requestmapping ("/loan") public class Loaninfocontroller extends Basecontroller {@RequestMapping ("")Public String Index (HttpServletRequest request) {return "Loan/index";}Use @requestmapping ("") to match to "/loan" and "/loan/". }
@Controller
public class Loaninfocontroller extends Basecontroller {@RequestMapping ("/loan")Public String Index (HttpServletRequest request) {return "Loan/index";}Use @requestmapping ("") to match to "/loan" and "/loan/". (Analysis is like this, no attempt)}
public class Loaninfocontroller extends Basecontroller {@RequestMapping ("/loan/")Public String Index (HttpServletRequest request) {return "Loan/index";}Use @requestmapping ("") to match only to "/loan/". The question is, "/loan" can be directly matched to, or after SPRINGMVC processed, and then matched to.
7.HttpServletRequest Get the port number. http://a.com:8080 Getlocalport can get 8080 getremoteport get a server-side port number like 61132, not the desired one. can refer to the summary of this article: http://blog.csdn.net/ranmudaofa/article/details/39785785 8.jquery Gets the problem of modifying the SRC, parent page and current page of the IFRAME. A.html<iframe src= "${base}/welcome.html" id= "mainFrame" frameborder= "0"Width= "80%" height= "x" ></iframe> an iframe in a.html, click on a button in a to update the SRC attribute of the IFRAME. After loading the welcome.html page, manually modify the src of the IFRAME, but the page is not refreshed.
Later, the issue was discovered through Chrome's debug. var mainframe=$ ("#mainFrame"); the MainFrame obtained in the sub-page does not have the SRC attribute.
Finally, a.html and b.html have found mainframe, but not the same element, why?
Workaround: Parent page: mainframe=$ ("#mainFrame"); Sub-page: mainframe=$ ("#mainFrame", window.parent.document); Equivalent to Window.parent.document.getElementById ("MainFrame");
If you write a generic method, you need to determine if SRC has a value.
the function name of 9.JS is the keyword. function Delete (acl,ename); "Delete" is a keyword in JS and cannot be used as the name of the functions.    This also shows that the Java template file with the ". html" suffix is more convenient, eclipse can give hints. Mom eggs, write their own components, to the hyperlink binding an event, "remove" method unexpectedly also seems to conflict, because I casually use a "a" method, is can respond.
10. The JSON parameter reception problem of wonderful flowers. Originally submitted with form form, there is a property name called "Amoun.yuan", so that the backend money Amount Object field yuan receive normal.
Now with the JSON request, the parameter name is "Amount.yuan" and the receive fails. "Amount.yuan": Amount.
How to say, if just can't receive the parameter, I express very understanding. But the error of the report is indeed 400,bad request.
I always thought it was, @RequestParam, that a parameter was not submitted.
Now finally understand, in the future resolutely no longer use "a.b" this form of the JSON parameters are sent.

2015 technical problems encountered in entrepreneurship: 1-10 (garbled-springmvc-jquery-json, etc.)

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.