anto
anto

Reputation: 325

How to get values passed in url to model and view controller?

I need to the get values passed in url in my jsp using jstl tags to be get in a method in model and view controller.

in my jsp iam having an option purchase on click of purchase it is mapped to a method where i need all the passed values

iam passing values like this on jsp

<a href="/licensing/purchaseMoreSeat.sp?${Constants.PART_NUMBER}=${suites.partNumber}&${Constants.ENTITLEMENT_ID_PARAM}=${suites.entitlementId}&${Constants.LICENSE_TYPE}=${suites.licenseType}&${Constants.QUANTITY}=1&&attribName=${Constants.EXISTING_ENT_ID}"/>

on click of purchase option i need to get all the values passed in url inside the method(using spring technology)

public purchaseMoreSeat()
{
}

please help me in resolving this. I am new to both java and spring.

Upvotes: 0

Views: 2843

Answers (1)

Japan Trivedi
Japan Trivedi

Reputation: 4483

I suggest you to use @RequestMapping annotation in your controller for mapping your url. It will be easy for you to get the url parameter values in the controller then. Please refere the following example.

@RequestMapping("/GetStateCombo")
    public void getStateCombo(@RequestParam String cmbCountryId, ModelMap map, HttpServletRequest request, HttpServletResponse response)

in the above example you can see the first argument in the function @RequestParam String cmbCountryId. It will match the parameter with same name in the url and bind its value to that parameter. After that you just need to access it in the function.

Hope this helps you.

Cheers.

Upvotes: 1

Related Questions