在Spring MVC Controller中获取查询字符串值
问题内容:
我有一个这样的引荐来源网址:
http://myUrl.com?page=thisPage&gotoUrl=https://yahoo.com?gotoPage
如何在Spring Controller中获取“ page”和“ gotoUrl”的值?
我想将这些值存储为变量,以便以后再使用。
问题答案:
您可以从HttpServletRequest接口使用getParameter()方法。
例如;
public void getMeThoseParams(HttpServletRequest request){
String page = request.getParameter("page");
String goToURL = request.getParameter("gotoUrl");
}