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