1

I am trying to pass clusterId=1 as parameter from <a href="http://192.168.11.134:8080/UniconnectConfigurationWeb/nodes?clusterId=1"> and get it into spring mvc controller through @PathParam("clusterId")Integer clusterId. But I'm getting 404 error.

Guide me how to pass parameter through anchor tag and how to hit controller and get the parameter value. I am sharing my code below,

 @RequestMapping(value = "/nodes?clusterId={clusterId}", method = RequestMethod.GET)
     public ModelAndView nodes(@RequestParam("clusterId")Integer clusterId,HttpSession session, HttpServletRequest request) {
         System.out.println(clusterId);
       return dashboard;
      }
    }
<c:url var="myURL" value="http://192.168.11.134:8080/UniconnectConfigurationWeb/nodes">
    <c:param name="clusterId" value="1"/>
</c:url>
StaticBeagle
  • 5,070
  • 2
  • 23
  • 34

1 Answers1

1

Here you are using clusterId as Request Parameter , and passing from client side to server side. but in your server side code you are used ?clusterId={clusterId} in Request Mapping annotation and you are trying to receive that request parameter with @RequestParam Annotation. here @RequestParam is enough for receiving Request Parameter. so, no need to use this ?clusterId={clusterId}`, this is not correct way of writing server side URL.

it may helps you for better understanding @RequestParam vs @PathVariable