我想在VisualForce上暴露裸xml/json

ega*_*gar 3 salesforce apex-code

我试图从VisualForce中公开自生成的XML(或JSON).但是我找不到覆盖apex:page组件上的父页面的方法,所以我得到了整个菜单,条形图和所有额外的html.

但我只想提供自我修复的xml.基本上我想这样做:

http://salesforceserverXX.com/apex/page ---->

内容

那可能吗?

Chi*_*hta 7

是的,这是可能的.以下VF代码输出JSON字符串.请注意showhedear和contentType参数.ControllerClass是托管"processRequest"方法的apexclass,它生成一个JSON字符串"requestReponse"

<apex:page controller="ControllerClass"
    contentType="text/javascript"
    showHeader="false"
    cache="true"
    expires="1"
    action="{!processRequest}">{!requestResponse}</apex:page>
Run Code Online (Sandbox Code Playgroud)