java – 如何使用HTTPServletRequest在spring中读取请求参数值

前端之家收集整理的这篇文章主要介绍了java – 如何使用HTTPServletRequest在spring中读取请求参数值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想使用HttpServletRequest从url读取requestParams数据

http://localhost:8080/api/type?name=xyz&age=20

我的控制器中的方法不会定义@RequestParam,它只是

@RequestMapping(value = "/**",method = RequestMethod.GET)
    public ResponseEntity

我想阅读请求只使用params而不是整个url.

最佳答案
首先,为什么要定义:

@RequestMapping(value = "/**",method = RequestMethod.GET)`

也许你应该使用:

@RequestMapping(value = "/api/type",method = RequestMethod.GET)

并阅读参数:

request.getParameter("name");
request.getParameter("age"):
原文链接:https://www.f2er.com/spring/431901.html

猜你在找的Spring相关文章