要實作下載的功能,英文后臺能夠取到值,但中文就取到亂碼
<table class="layui-table">
<colgroup>
<col width="100">
<col width="100">
<col width="100">
</colgroup>
<thead>
<tr>
<th>序號</th>
<td>戶主</td>
<td>檔案名稱</td>
<td>檔案分類</td>
<td>存盤期限</td>
<td>存盤介質</td>
<td>檔案</td>
<td>上傳時間</td>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach var="files" items="${list}" varStatus="status"> <!-- items獲取action傳來的key值,varstatus回圈序號 index從0開始,count從1開始-->
<tr>
<td>${files.sort}</td>
<td>${files.family.host}</td>
<td>${files.file}</td>
<td>${files.type}</td>
<td>${files.term}</td>
<td>${files.carrier}</td>
<td>
<a href="javascript:window.location.href='<%=basePath %>download.html?filePath=${files.file}';" class="layui-btn layui-btn-sm">下載</a>
</td>
<td>${files.uploadtime}</td>
<td>
<a href="javascript:window.location.href='<%=basePath%>files/toupdate.html?id=${files.id}';" class="layui-btn layui-btn-warm layui-btn-sm">修改</a>
<a href="javascript:window.location.href='<%=basePath%>files/del.html?id=${files.id}&isadmin=1';" class="layui-btn layui-btn-danger layui-btn-sm">洗掉</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>

圖片的檔案名稱一列說明${files.file}已經在頁面中取到中文值“劇本”顯示,現在我要點擊下載傳送這個${files.file}名稱去后臺,英文的就可以正常收到,中文就只有亂碼
@Controller
public class DownLoadController {
@RequestMapping(value="https://bbs.csdn.net/download")
public String download(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException{
request.setCharacterEncoding("utf-8");//這行并沒有用
String filePath=request.getParameter("filePath");
System.out.println(filePath);//中文亂碼,英文正常
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/54506.html
標籤:HTML(CSS)
下一篇:這多個ID怎么寫link
