0
我正在使用Play Framework 2.0, 我試圖打印出一張表格,根據我的數據類型,我的程序會輸入不同的數據。我已經想通了如何定義使用isInstanceOf類我輸入的,但是當我做一個列表,它返回:Play Framework 2.0,Scala定義輸入類型並打印列表
non-variable type argument models.Medication in type java.util.List[models.Medication] is unchecked since it is eliminated by erasure
下面是我的代碼:
@(title: String)(content: Object)
<tr>
<td>@title</td>
@if(content.isInstanceOf[Date]) {
<td>@content.asInstanceOf[Date].format("yyyy-MM-dd")</td>
} else{
@if(content.isInstanceOf[List[Medication]]){
<td>
<table>
@for(a <- content) {
@a.name<br>
}
</table>
<td>
} else {
<td>@content</td>
}
}
請幫忙...
這只是一個警告權?它是否阻止編譯代碼?警告告訴你,在運行時''Medication'是'List [Medication]'被擦除,即使內容只是一個List [Object],JVM也可能返回true。 – huynhjl 2013-03-21 04:03:40
它在Play上運行,並阻止我編譯...(或者有辦法關閉警告?) – hook38 2013-03-21 04:17:45