search

Home  >  Q&A  >  body text

java - @RequestParam 获取参数值有问题

大家讲道理大家讲道理2801 days ago788

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-18 10:47:41

    Did you include two pIDs in the parameters? For example:

    http://.../showCorrelation?pID=34cb...&pID=3574...
    

    req.getParameter("pID") will only get one of them (if there are multiple parameters with "pID" as the key parameter, please check the Javadoc of Servlet API or the source code of Servlet Container for the specific number). It will get all of them. Parameters with "pID" as key must use req.getParameterValues();

    Check how Spring MVC explains @RequestParam, or see how the source code implements it. Will it take out all the parameters with "pID" as the key? If there are more than one, use commas to connect them?

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 10:47:41

    There is a problem with the return view, the reason is that we return json不返回视图,所以应该在HandlerExceptionResolver中将return null改为return new ModelAndView();

    reply
    0
  • Cancelreply