如何在Spring MVC中请求完整的查询字符串?
问题内容:
在Spring MVC中,我可以这样做来获取查询字符串中的项目值:
public void sendMessage(HttpServletResponse response,
@RequestParam("Session Id") String sessionId,
但是,如何获取完整的查询字符串作为一个长字符串呢?即我不想要单个参数,而是想要整个东西?
非常感谢!
问题答案:
将HttpServletRequest
as参数添加到方法中,并从请求中获取查询字符串:
public void sendMessage(HttpServletRequest request,
HttpServletResponse response {
String queryString = request.getQueryString();
}