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!
It is actually much easier to pass URL parameters to Lighning components in a community page. The "trick" is to expose your attributes at design time to the page, so they show up in the Lightning page designer as component properties. You do that in the design definition (the .design file):

```
<design:component label="Sample">
   <design:attribute name="someParam" label="Make Parameters great again" />
</design:component>

```

this presumes that you component has a parameter `someParam` in its attribute definition (in the .cmp file):

```
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" controller="someController">
    <aura:attribute name="someParam" type="String" />
    .... stuff here ...
</aura:component>

```

Let's presume your url looks like `....?color=blue` then you add into the property value of your component, after you dragged it onto the lightning page in community builder:

```
 {!color}

```

This will pull the value of the color URL parameter and hand it to the someParam attribute of your component. No JS required.

Hope that helps

Update:
=======

Passing URL parameters using component properties is **not** officially supported and only works on a full page load (which is slow).