0
想法是將SMB文件URL或普通網站URL作爲GET參數傳遞給Spring Web MVC控制器。但是也有一些問題,正確的輸出:使用不同URL的意外GET值
GET值:
- http://localhost:8080/docapp/document/test/42 - >獲得值:42
- http://localhost:8080/docapp/document/test/www.google.com - >獲得值:www.google
- http://localhost:8080/docapp/document/test/www.google.com/ - > GET值:www.google.com
- http://localhost:8080/docapp/document/test/%5C%5Csmbserver%5Caccounts%5Ctestaccount%5CWas_muessen_Programme_verarbeiten.docx - >空白頁,沒有例外
正如你所看到的第二個和第四個URL示例不起作用,所以我的問題:
- 我該如何處理第二個例子?正確的輸出應該是www.google.com。
- 在第四個例子中會發生什麼?
設置信息:一個Ubuntu 14.04 LTS 64和Tomcat 8用於
爪哇
@RequestMapping(value="/document/test/{url}", method=RequestMethod.GET)
public String test(@PathVariable String url, Model model) throws IOException
{
model.addAttribute("url", url);
return "test";
}
HTML
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Value: ${url}</p>
</body>
</html>
而不是pathVariable。使用請求對象獲取url – Pratik 2015-04-01 09:16:01
嘗試將URL編碼兩次或三次並將其傳遞到URL和服務器端只需完全解碼URL – ShihabSoft 2015-04-01 09:17:29