从httpservlet请求中读取请求参数

时间:2018-01-20 13:48:02

标签: java rest spring-mvc

我使用休息服务。我有以下要求。 http://127.0.0.1:29070/webbrokerproxy/wbservice/secure/basket/wbrokere 在这里我使用wbrokere作为请求参数。

@RequestMapping(value = "/basket/{brokerid}", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getAllBasket(@PathVariable("brokerid") String brokerid,HttpServletRequest request) throws PTWebException {
    Enumeration<String> parameterNames = request.getParameterNames();
    while (parameterNames.hasMoreElements()) {
        String paramName = parameterNames.nextElement();
        String[] paramValues = request.getParameterValues(paramName);
        for (int i = 0; i < paramValues.length; i++) {
            String paramValue = paramValues[i];
            log.info("paramname : " + paramName + "param value : " + paramValue);
        }
    }

    Map<String, Object> baskets = basketService.getBrokerBaskets(brokerid);
    if (baskets != null)
        return new ResponseEntity<Map<String, Object>>(baskets, HttpStatus.OK);
    else
        return new ResponseEntity<Map<String, Object>>(baskets, HttpStatus.NO_CONTENT);
}

现在假设从httpservelt请求我需要记录所有请求参数名称并重新记录我如何记录它?

0 个答案:

没有答案