1. 程式人生 > >2015年工作中遇到的問題121-130

2015年工作中遇到的問題121-130

121.Java的equals,經常被坑。
project的status是Short型別的變數。
project.getStatus().equals(2);false


整數2預設的型別的int,有這個印象,網上也是這麼說的。
我想通過debug求證下,看看Short的equas,但是那個obj竟然無法“watch”,debug模式也看不出型別,鬱悶。


這個時候2被當作Integer,通過debug發現的。(這是我debug之前的“想當然”,機智反被機智誤啊)


203 == project.getStatus(),為true,會自動進行型別轉換。


122.maxUploadSize的大小不能用乘法1*2這種,必須輸入整數。
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="1048*57600" />
<property name="maxInMemorySize" value="10240" />
</bean>
java.lang.NumberFormatException: For input string: "1048*57600"


如果上傳的圖片大小超過了限制,報錯~
org.springframework.web.multipart.MaxUploadSizeExceededException: 
Maximum upload size of 1024 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: 
the request was rejected because its size (5849) exceeds the configured maximum (1024)


123.Mybatis引入資源,placeholder屬性解析失敗。


spring-resource.xml
<import resource="classpath:spring-mybatis-config.xml" />
<import resource="classpath:spring-fastdfs-config.xml" />


可行的:
  spring-mybatis-config
  <context:property-placeholder location="classpath:*.properties" />
  spring-fastdfs-config
  不配置property-placeholder
  
 不可行的
  spring-mybatis-config
  <context:property-placeholder location="classpath:jdbc.properties" />
  spring-fastdfs-config
   <context:property-placeholder location="classpath:fast.properties" />

  比較奇怪的是,其它專案中,類似的配置就可以。
  property-placeholder 存在衝突,無效等問題,沒有搞清楚具體原因。
  
124.Git可以使用.gitignore檔案,忽視某個目錄。
/target/
/log4j/


2個目錄的變動,就不會被記錄了。


每次提交的時候,/.settings目錄下的檔案,都出現在對話方塊裡,但是我又不想提交,不方便使用“全選”。
解決辦法,手動在.gitignore檔案中加入一條/.settings。


一次性搞定這個煩人的問題~
我真是機智啊~


125../configure --prefix=/home/
prefix設定安裝到的目錄

126.if ($w != "")。
Nginx的if語句,左右貌似需要空格~
坑~


127.開啟紅警2提示"fatal"string manager failed to initilaized propely。
如果系統是VISTA/WIN7,則右鍵點選“以管理員模式執行”。
參考資料:http://wenwen.sogou.com/z/q1702977128.htm


128.VIM刪除一行。
在非編輯模式下,直接按“dd”。切記,編輯模式下是沒有用的,會直接輸入2個“d”字元。


129.id的初始值為“”,不是null和undefined,坑啊。
<input type="hidden" name="id" id="id"> 


130.Java不可變物件。
   check(null,null);
private void check(Long maxId, Integer limit) {
if (maxId == null) {
maxId = Long.MAX_VALUE;
}
if (limit == null || limit <= 0 || limit > 50) {
limit = 10;
}
}
呼叫之後,limit仍然是null。
Integer也是“不可變物件”。