Question: I am new to communities in lightning and I am trying to figure out a way to directly fetch the URL parameters into the lightning component attributes using the 
{! urlParamName} expressions.

for example : 

```
https://www.someurl.com/page?name=somename&surname=somesurname

```

My lightning component will be : 

```
<aura:component>

    <!-- Parameters Available in URL-->
    <aura:attribute name="name" type="String">
    <aura:attribute name="surname" type="String">

    <!--It will get name parameter from URL directly-->
    Name is : {!v.name} 

    <!--It will get surname parameter from URL directly-->
    SurName is : {!v.surname}

</aura:component>

```

I am trying to figure out a way which cannot includes JS.
Currently I am using Lightning JS to get these parameters.

Answer: 
First thing first. You have written apex:attribute in your question which is not valid, you should use aura:attribute.

Next, you have to declare the attributes in the app, not in the component in order to fetch them from the URL.

```
<aura:application >
    <aura:attribute name="name" type="String"/>
    <aura:attribute name="surname" type="String"/>
    Name is : {!v.name} 
    SurName is : {!v.surname}
</aura:application>

```

This works perfectly fine.

**UPDATE:**
After coming to know that Tarique is looking for a solution in components in community, I did some research and [this guy](https://developer.salesforce.com/forums/?id=906F0000000g1blIAA) has done a good job for this.

So basically you need to fetch the params using the JS controller. Handle the init event and then do the following to fetch the URL params:

```
doInit : function(component, event, helper) {
        var sPageURL = decodeURIComponent(window.location.search.substring(1)); //You get the whole decoded URL of the page.
        var sURLVariables = sPageURL.split('&'); //Split by & so that you get the key value pairs separately in a list
        var sParameterName;
        var i;

        for (i = 0; i < sURLVariables.length; i++) {
            sParameterName = sURLVariables[i].split('='); //to split the key from the value.

            if (sParameterName[0] === 'firstName') { //lets say you are looking for param name - firstName
                sParameterName[1] === undefined ? 'Not found' : sParameterName[1];
            }
        }
        console.log('Param name'+sParameterName[0]);
        console.log('Param value'+sParameterName[1]);
    }

```

I have tried this in my org and it worked!
Based on Damon Shaw's code, just add this helper method:

```
getUrlParameter : function(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
}

```