How to get base url in Visualforce?

{!$Site.BaseUrl} is used to get base url in Visualforce.

Sample Code;

Visualforce Page:

<apex:page controller="Sample" sidebar="false">
    <apex:repeat value="{!listAcct}" var="a">
        <a href="{!$Site.BaseUrl}/{!a.Id}" target="_blank">{!a.Name}</a><br/>


Apex Controller:

public class Sample {
    public List < Account > listAcct {get;set;}
    public Sample() {
        listAcct = [ SELECT Id, Name FROM Account ];




No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit