相思资源网 Design By www.200059.com

复制代码 代码如下:
public class DeviceAction extends AbstractAction implements ModelDriven<Device> {
    private static Log log = LogFactory.getLog(DeviceAction.class);
    private Device device=new Device(); //只能json化 模型驱动的bean
    private String result; //无法返回reslut的json值

   
    public String getResult(){
        return result;
    }
    public void setResult(String result){
        this.result=result
    }
    public DeviceDTO getModel() {
        return device;
    }
    public Device getDevice() {
        return device;
    }
    public void setDevice(Device device) {
        this.device = device;
    }
}            

xml配置:

复制代码 代码如下:
<action name="queryPu"
            class="com.jxj.bss.web.actions.DeviceAction"
            method="queryPu">
            <interceptor-ref name="isLogin"></interceptor-ref>
            <result type="json">
                <param name="includeProperties">
                    resultCode
                </param>
            </result>
        </action>

解决办法:

复制代码 代码如下:
<action name="queryPu"
            class="com.jxj.bss.web.actions.DeviceAction"
            method="queryPu">
            <interceptor-ref name="isLogin"></interceptor-ref>
            <result type="json">
                <param name="root">action</param>
                <param name="includeProperties">
                    resultCode
                </param>
            </result>
        </action>

标签:
action,ModelDriven,json

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“struts2中action实现ModelDriven后无法返回json的解决方法”

暂无struts2中action实现ModelDriven后无法返回json的解决方法的评论...