...
- Add the map inside a package that extends "json-default"
- Add a result of type "json"
Example with Convention Plugin Configuration:
Code Block | ||||
---|---|---|---|---|
| ||||
import java.util.HashMap;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
@Result(type = "json")
public class JSONExample extends ActionSupport {
// action code
}
|
Example with XML Configuration:
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="example" extends="json-default"> <action name="JSONExample" class="example.JSONExample"> <result type="json"/> </action> </package> </struts> |
...