0
我有一個csv文件。我需要使用jsp在html表格中顯示csv文件內容。我使用open csv編寫了所需的代碼。是的,它已成功顯示在HTML表格中。但是一些神祕的字符代替「-?- 1 -?-
」代替「- 1-
」,這些問號是不必要的。轉換爲ANSI
我曾試圖轉換值以下列方式爲ANSI,消除神祕人物條目:
csvReader = new CSVReader(reader);
int rowCount = 1;
while ((line = csvReader.readNext()) != null) {
%>
<tr>
<td class="heading" width="30"><%=rowCount%></td>
<%
for (int i = 0; i < line.length; i++) {
if (rowCount == 1) {
%>
<td class="ex-headding" width="120"><strong><%=line[i]%></strong></td>
<%
} else {
//this is the code to convert into ansi
String utf = line[i];
byte[] data = utf.getBytes("ASCII");
line[i] = new String(data);
%>
<td><%=line[i]%></td>
<%
}
}
%>
但問題仍然存在。是轉換的正確方式進入ANSI
我嘗試了以上所有可能的方式,它不工作。 Iam實際在Linux中部署代碼。 – user3173486
擴展了答案,指責了CSVReader。雖然你可能已經(記錄)檢查。 –