加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 01:23:43 所属栏目:大数据 来源:网络整理
导读:我想使用HttpServletRequest从url读取requestParams数据 http://localhost:8080/api/type?name=xyzage=20 我的控制器中的方法不会定义@RequestParam,它只是 @RequestMapping(value = "/**",method = RequestMethod.GET) public ResponseEntity 我想阅读请求

我想使用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"):

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读