Get current page query string parameters in apex
This would be a clean way to do it:
apexPages.currentPage().getParameters().get();
// For URL - http://test.salesforce.com/apex/helloworld?q=texas
//use the following
String queryString ='';
queryString = ApexPages.currentPage().getParameters().get('q');
Source
Parameters passed to the page through URL can be accessed in controller using below syntax,
String parameterValue = ApexPages.currentPage().getParameters().get('parameterName');
Usually it is used in constructor of controller to get value and then do operations based on the parameter value.