問題:
get或者post中提交的內容可能有空格、#等特殊字符,不做處理的話可能解析錯誤。
解決:
html中:
<a th:href="@{/listSgrna(id=${item.getGeneId()},geneName=${item.getGeneName()},genome=${genome},sgrnaNum=${sgrnaNum})}">show</a>
controller里:
需要對字符串中可能存在的blank,#等做處理,直接用URLDecoder就好了。
// 提供下載鏈接時(拼接url),文件名要做轉換 (detail函數)
URLEncoder.encode(tempInfo[2], "UTF-8")
// latestResult是上面url的一部分,需要decode獲得真正字符串
String attachFileName = URLDecoder.decode(latestResult, "utf-8").trim();