This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-site by this push: new e8f8b20 Updates production by Jenkins e8f8b20 is described below commit e8f8b20a1be1a7de6a3e862d7d93eaadd693b1ea Author: jenkins <bui...@apache.org> AuthorDate: Sun Oct 15 15:18:22 2017 +0000 Updates production by Jenkins --- content/plugins/json/index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/plugins/json/index.html b/content/plugins/json/index.html index 1a4ff60..0ea9c27 100644 --- a/content/plugins/json/index.html +++ b/content/plugins/json/index.html @@ -148,6 +148,7 @@ <li><a href="#jsonp" id="markdown-toc-jsonp">JSONP</a></li> <li><a href="#content-type" id="markdown-toc-content-type">Content Type</a></li> <li><a href="#encoding" id="markdown-toc-encoding">Encoding</a></li> + <li><a href="#customizing-the-output" id="markdown-toc-customizing-the-output">Customizing the output</a></li> </ul> </li> <li><a href="#example" id="markdown-toc-example">Example</a> <ul> @@ -570,6 +571,19 @@ given result add encoding param as below:</p> </code></pre> </div> +<h3 id="customizing-the-output">Customizing the output</h3> + +<p>Since Struts 2.5.14, you can implement the <code class="highlighter-rouge">org.apache.struts2.json.JSONWriter</code> interface to customize the generated json response. +The implementation should then be defined in <code class="highlighter-rouge">struts.xml</code> like:</p> + +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><struts></span> + <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.json.JSONWriter"</span> <span class="na">name=</span><span class="s">"myJSONWriter"</span> <span class="na">class=</span><span class="s">"com.mycompany.MyJSONWriter"</span> + <span class="na">scope=</span><span class="s">"prototype"</span><span class="nt">/></span> + <span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.json.writer"</span> <span class="na">value=</span><span class="s">"myJSONWriter"</span><span class="nt">/></span> +<span class="nt"></struts></span> +</code></pre> +</div> + <h2 id="example">Example</h2> <h3 id="setup-action">Setup Action</h3> -- To stop receiving notification emails like this one, please contact ['"commits@struts.apache.org" <commits@struts.apache.org>'].