示例URL:
../search/?attr1=value1&attr2=value2&attr4=value4
我不知道attr1、att2和attr4的名称。
我希望能够做这样的事情(或类似的,不关心,只要我可以访问请求参数名称->值的映射:
@RequestMapping(value = "/search/{parameters}", method = RequestMethod.GET)
public void search(HttpServletRequest request,
@PathVariable Map<String,String> allRequestParams, ModelMap model)
throws Exception {//TODO: implement}
我如何实现这与Spring MVC?
有两个接口
org.springframework.web.context.request.WebRequest
org.springframework.web.context.request.NativeWebRequest
允许通用请求参数访问以及请求/会话属性访问,而不需要绑定到本机Servlet/Portlet API。
Ex.:
@RequestMapping(value = "/", method = GET)
public List<T> getAll(WebRequest webRequest){
Map<String, String[]> params = webRequest.getParameterMap();
//...
}
附注:有一些文档是关于可以用作控制器参数的参数的。
有两个接口
org.springframework.web.context.request.WebRequest
org.springframework.web.context.request.NativeWebRequest
允许通用请求参数访问以及请求/会话属性访问,而不需要绑定到本机Servlet/Portlet API。
Ex.:
@RequestMapping(value = "/", method = GET)
public List<T> getAll(WebRequest webRequest){
Map<String, String[]> params = webRequest.getParameterMap();
//...
}
附注:有一些文档是关于可以用作控制器参数的参数的。