簡體   English   中英

如何像使用HttpServletRequest一樣從Spring MVC中的org.springframework.web.context.request.WebRequest中獲取requestUrl?

[英]How can I get the requestUrl from org.springframework.web.context.request.WebRequest in Spring MVC like we do using HttpServletRequest?

像我們通過HttpServletRequest(getRetuestUrl())獲取一樣,如何從Spring MVC中的WebRequest獲取URL?

Spring提供了添加HttpServletRequest作為方法參數的選項。 調用控制器時,Spring將自動注入該參數。

這是代碼。

@RequestMapping(path = {"new", "standard/new"}, method = RequestMethod.GET)
public String createRequest(HttpServletRequest request) {
    System.out.println(request.getRequestURI());
    System.out.println(request.getRequestURL());
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM