您引用的 wiki 页面 ( http://wiki.developerforce.com/index.php/Authenticating_Users_on_Force.com_Sites ) 是去这里的方式,只需更改以下代码片段:
public class SiteLoginController {
public String username {get; set;}
public String password {get; set;}
public PageReference login() {
String startUrl = '/my_site_homepage'; // change the startUrl
return Site.login(username, password, startUrl);
}
public SiteLoginController () {}
public static testMethod void testSiteLoginController () {
// Instantiate a new controller with all parameters in the page
SiteLoginController controller = new SiteLoginController ();
controller.username = 'test@salesforce.com';
controller.password = '123456';
System.assertEquals(controller.login(),null);
}
}
正如您在 PageReference 中看到的那样,login
您startUrl
只需将其更改为登录后要加载的页面。