字符串參數我有兩個參數長字符串一個Spring控制器:RequestMapping包含URL
@RequestMapping(value = "/webpage")
@Controller
public class WebpageContentController {
//...
@RequestMapping(value = "{webpageId}/{webpageAddress}", method = RequestMethod.GET)
public String contentWebpageById(@PathVariable long webpageId, @PathVariable String webpageAddress) {
System.out.println("webpageId=" + webpageId);
System.out.println("webpageAddress=" + webpageAddress);
//...
}
//...
如果我調用它是這樣的:
http://localhost:8080/webarch/webpage/1/blahblah
一切都很好:
webpageId=1
webpageAddress=blahblah
但是,如果我用斜線傳遞String參數(在本例中爲URL地址):
http://localhost:8080/webarch/webpage/1/https://en.wikipedia.org/wiki/Main_Page
我得到一個錯誤:
org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/webarch/webpage/1/https://en.wikipedia.org/wiki/Main_Page] in DispatcherServlet with name 'appServlet'
如何通過這樣的參數?
有沒有簡單的方法來做到這一點。 WebMVC維護者明確拒絕支持它的請求。 – chrylis