20 problems encountered during work in 181: 181-200 ,-
181. commons-email is required in the project and you want to introduce it through maven.
<Dependency>
<GroupId> org. apache. commons </groupId>
<ArtifactId> commons-email </artifactId>
<Version> 1.2 </version>
</Dependency>
A problem occurred while downloading javax-mail.
I tried various methods and finally deleted Maven from Classpath. Then I wanted to add maven to Classpath,
The result is always failed.
First, try to delete the project and then re-import it. The result still does not work.
Finally, Disable Maven features of the project, Disable maven nature, and then convert the project to maven. At this time
Maven is added to Classpath, And the jar package is downloaded smoothly.
182. checkbox check box form submission.
<Form action = "B .html" method = "post">
<Input type = "checkbox" name = "bike" value = "1"/>
I have a bike
<Br/>
<Input type = "checkbox" name = "car"/>
I have a car
<Input type = "submit" value = "submit"/>
</Form>
If not selected, it will not be submitted.
If selected, if no value is set, the value is on, for example, car = on.
If the value has a value, such as 1, the car = 1 is submitted.
183. URL of the hyperlink. If the URL contains Chinese characters, garbled characters may occur.
Freemarker uses url encoding for the Chinese name.
<# Setting url_escaping_charset = 'utf-8'>
<# Assign url = "$ {base}/search/search.html? Keyword =$ {keyword? Url} "/>
Http://fansunion.cn/search/search.html? Keyword = % E5 % A4 % A7 % E5 % AD % A6 & pageNo = 2 & pageSize = 20
184. Maven, Eclipse, and other frequently encountered "invalid characters.
Error: Invalid character: \ 65279
. Java files are UTF-8 with BOM.
Open it with Nodepad and save it as without BOM.
185. A strange problem.
A static variable public static String export eindexdir = "c: // lucene ";
The program changes to the value read from the configuration file somewhere, such as/root/lucene.
How does the value of the online Linux environment change to "/root/C:/lucene ". I really don't understand.
It is normal to run locally.
Finally, set the initial value of lucendexdexdir to null.
186. replace.
Replace into is similar to insert. The difference is that replace into first tries to insert data into the table,
1. If this row of data is found in the table (determined based on the primary key or unique index), delete the row of data and insert new data.
2. Otherwise, insert new data directly.
Note that the table to which data is inserted must have a primary key or a unique index! Otherwise, replace into inserts data directly, which leads to duplicate data in the table.
In addition to the primary key, the unique index is also possible, unique.
A unique index can be a field or multiple fields.
187. Nginx domain name jump and "= ".
Server_name fansunion.cn www.fansunion.cn blog.fansunion.cn;
If ($ host = 'blog .fansunion.cn '){
Rewrite ^/(. *) $ http://fansunion.cn/permanent;
}
If ($ host! = 'Fansunion. cn '){
Rewrite ^/(. *) $ http://fansunion.cn/#1 permanent;
}
Redirect blog.fansunion.cn to Fansunion.cn permanently.
Www.fansunion.cn. Remove www and set it to fansunion.cn.
Use "=" instead of "=" to determine equal conditions ".
188. When you log on and jump back, the browser may not refresh the page again, using the previous "cache ".
Refresh manually.
189. Value of Mybatis, special scenario.
List <Map <String, Object> findAllByUserId (Long userId );
<Select id = "findAllByUserId" resultType = "java. util. Map">
<If test = "userId! = 1 "> and ur. user_id =#{ userId} </if>
Order by p. parent_acl asc, p. sort_no, p. acl
</Select>
In this case, a problem occurs. # {userId} can get the value.
Test = "userId! = 1 "userId, error, prompt:
"There is no getter for property named 'userid' in 'class java. lang. long '".
You can use Map or Bean for the parameter type, or use @ Param ("userId") to mark it.
190. Java Long comparison.
Long id = 1L;
Id. equals (1 );
Returns false.
Id. equals (1L );
For Long type, the specified L must be displayed, indicating that the integer is of the Long type.
191. The <if> </if> expression cannot be directly used in the @ Select annotation of Mybatis, which is only available in xml.
192. For Mysql replace into, perform delete first and then insert.
The table's primary key id will change constantly.
Id user_id role_id, user_id and role_id are used as the Union unique index.
193. The customer encountered a problem. When the database calls the stored procedure, the inserted data is garbled.
Call p_user_register ('email2', 'leiwen', '000000', '11', 1, @ a, @ desc );
Select @;
Select @ desc;
Baidu Knows how to call and how to obtain the return value from Baidu.
I didn't see garbled characters locally. I guess the client may be using utf8 encoding not specified during mysql installation.
Later I found the problem. If the original database encoding is GBK, I directly changed the database encoding to UTF8. Although the encoding has changed, it is still prone to garbled characters.
Re-build the database, select utf8 encoding, then import data, or execute the stored procedure, there will be no garbled characters.
194. When an SQL statement is imported from mysql, the system gets stuck and the subsequent normal data cannot be imported.
The problem usually occurs when SQL is imported using visual tools such as mysql-front.
If this problem occurs, source c:/p2p. SQL is directly in the doscommand line, even if an error occurs,
It will also be skipped directly, without affecting the correct import.
195. A good function of Eclipse was found today.
Project name-right-click menu-Source-> Fromat, Clean up, etc.
196. In the evening, Chinese chess 2 was open-source to CSDN-Code. As a result, the push failed due to the large sound file.
Therefore, delete the local file first, synchronize it, and submit the large files in batches.
197. The check box cannot submit multiple values in the last two days.
Today, I found the cause of the problem. The backend form component was written by a colleague and has a bug.
At first, SpringMVC thought that the method for receiving parameters was incorrect. Later, when I thought about viewing HTTP requests, I found that there was only one request.
Write another native form and find that there can be multiple forms, so the problem is fixed.
198. When submitting a checkbox form, it is appropriate to use an array to receive it. If map is not available, only one form can be received and multiple values will be overwritten.
<Input type = "checkbox" name = "privileges" value = "$ {item. acl}"/>
Public void doadd (RoleForm params, Model model ){
}
RoleForm {
Private Integer id;
Private String name;
Private String remark;
Private Map <String, Object> privilege;
Private Integer [] privileges;
}
199. Limitations of Map, the type is not clear enough. Without clear Model, Map is not conducive to object-oriented programming, and cannot fully utilize the built-in features of java, such as equals.
List <Map <String, Object> ownPrivilegeList = privilegeService. listByRole (id );
List <Map <String, Object> privilegeList = privilegeService. listAll ();
The map in the two sets is not the same object, but their IDs are the same.
If it is an object, override the equals method and compare it by id, you can use
List. contains method, while map can only be handwritten by yourself.
Private boolean contains (List <Map <String, Object> ownPrivilegeList,
Map <String, Object> p ){
For (Map <String, Object> own: ownPrivilegeList ){
If (own. get ("acl"). equals (p. get ("acl "))){
Return true;
}
}
Return false;
}
The MapUtils method of Apache does not have this comparison.
200. If the "replace into" method of mysql is used to implement the add method, it is not appropriate to use the add method name.
This is also called because of the update method.
@ Insert ("replace into p2p_user_role (user_id, role_id) values (# {user_id}, # {role_id })")
Void addOrUpdate (Map <String, Object> params );
It is better to use addOrUpdate, so that both the add and update Methods on the service layer can call the underlying dao method without ambiguity.
First: http://fansunion.cn/article/detail/565.html