mirror of
https://github.com/apache/struts.git
synced 2026-08-07 07:37:20 +00:00
WW-4034 Allows to use custom JSONwriter
This commit is contained in:
@@ -25,5 +25,6 @@ package org.apache.struts2.json;
|
||||
*/
|
||||
public class JSONConstants {
|
||||
|
||||
public static final String JSON_WRITER = "struts.json.writer";
|
||||
public static final String RESULT_EXCLUDE_PROXY_PROPERTIES = "struts.json.result.excludeProxyProperties";
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -63,8 +64,8 @@ public class JSONUtil {
|
||||
private static JSONWriter writer = new DefaultJSONWriter();
|
||||
|
||||
@Inject
|
||||
public static void setWriter(JSONWriter writer) {
|
||||
JSONUtil.writer = writer;
|
||||
public static void setContainer(Container container) {
|
||||
JSONUtil.writer = container.getInstance(JSONWriter.class, container.getInstance(String.class, JSONConstants.JSON_WRITER));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
"http://struts.apache.org/dtds/struts-2.5.dtd">
|
||||
|
||||
<struts>
|
||||
<bean type="org.apache.struts2.json.JSONWriter" name="default" class="org.apache.struts2.json.DefaultJSONWriter"/>
|
||||
<bean type="org.apache.struts2.json.JSONWriter" name="json" class="org.apache.struts2.json.DefaultJSONWriter"/>
|
||||
<constant name="struts.json.writer" value="json"/>
|
||||
|
||||
<bean class="org.apache.struts2.json.JSONUtil" static="true"/>
|
||||
|
||||
<package name="json-default" extends="struts-default">
|
||||
|
||||
Reference in New Issue
Block a user