027_System.VisualforceException: Read access denied for null, controller action methods may not execute [closed]

https://salesforce.stackexchange.com/questions/123968/need-help-system-visualforceexception-read-access-denied-for-null-controlle

 

System.VisualforceException: Read access denied for null, controller action methods may not execute [closed] // System.VisualforceException: 更新访问权限因为 Account 而被拒绝,控制器操作方法可能无法执行

这类问题通常有几种情况;

public without sharing class TestController {
    public Contact myCon {get ; set; }
    public String mobNumber {get;set;}
    public TestController() {
        myCon = [SELECT Id, Name, FirstName, MobilePhone FROM Contact WHERE Id =: '003N000000SDkc6'];
    mobNumber=myCon.MobilePhone ;
    }

    public void test(){
        System.debug('@@ ' + JSON.serialize(myCon));
        myCon.MobilePhone=mobNumber ;
        update myCon;
    }
}
<apex:page showHeader="true" sidebar="true" controller="TestController">
<apex:form>
    <apex:inputText value="{!mobNumber}" />
    <apex:commandButton value="save" action="{!test}" />
</apex:form>

 请不要使用{!myCon.MobilePhon}

posted @ 2017-06-13 13:28  BandariFang  阅读(1392)  评论(0编辑  收藏  举报