FreeMarker / S2SH 各種報錯解決方案


1. org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.fcms.core.entity.NubbMovie.isMovie  

持久化對象-映射文件-數據庫表中對應字段數據類型不符

 

2. freemarker.core.ParseException: Encountered "" at line 187, column 49 in WEB-INF/user_base/face_com_www/tuike/movie/actor.html. Was expecting one of: ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... "${" ... "#{" ...

標簽錯誤,可能是由於</#list>寫成了<#/list>  不合法造成無法解析而報錯

 

3. freemarker.core.ParseException: Unexpected end of file reached. Unclosed list directive.

 Unclosed list---<#list>未含結束標簽

 

4. org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of

對應bean中set方法數據類型和hibernate配置文件中定義的類型是否一致。

 

5.org.hibernate.exception.SQLGrammarException: could not initialize a collection 

檢查以下內容是否出錯:

inverse="true" 是否在一對多或多對多中設定一方去維持兩者之間的關系; 或者用注解的方式配置則是:

 

//One
@OneToMany(fetch = FetchType.LAZY, mappedBy = "movie_id", cascade = {
   CascadeType.PERSIST, CascadeType.REFRESH }, targetEntity = Users.class)
 @Column(name = "movie_id", nullable = false, updatable = false)

 

//Many
@ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "movie", insertable = true, updatable = true, nullable = false)

cascade="delete" 級聯刪除

<key>
  <column name="movie_id" /> 此處應填上另一方表的字段名!
</key>

 

6.  freemarker 中在一循環列表中,判斷某條記錄是否包含指定的字符串。

  <#list al as l>
    <#if l.info?indexof("xxx") != -1>
      ${l.name!}
    </#if>
  </#list>

  本以為很簡單的一個邏輯判斷語句,但是在實際操作中,指定的字符串“xxx”,不是已知的,而是一個變量,這里我就用str表示

  那么l.info?indexof(str) != -1 這條語句將會報args參數錯誤! 原因在於傳遞進來的str類型不是string

  在此i.info?indexof("str") != -1 不會報錯,但是很明顯,這樣的話str變量將不會被解析。

  為了達到邏輯語句成立,我只能在l.info那做文章---將每個元素用 , 隔開,然后將indexof()判斷的字符串改變,得到indexof("," + str + ",");

  此時有人會提出,我可以直接寫成這樣就行了啊----indexof("\"" + str +"\"");   答案是否定的

 

7. No row with the given identifier exists: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.fcms.cms.entity.CmsChannel#1679]

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM