手机
当前位置:查字典教程网 >编程开发 >JSP教程 >struts2中action实现ModelDriven后无法返回json的解决方法
struts2中action实现ModelDriven后无法返回json的解决方法
摘要:复制代码代码如下:publicclassDeviceActionextendsAbstractActionimplementsModelDr...

复制代码 代码如下:

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"

method="queryPu">

<interceptor-ref name="isLogin"></interceptor-ref>

<result type="json">

<param name="includeProperties">

resultCode

</param>

</result>

</action>

解决办法:

复制代码 代码如下:

<action name="queryPu"

method="queryPu">

<interceptor-ref name="isLogin"></interceptor-ref>

<result type="json">

<param name="root">action</param>

<param name="includeProperties">

resultCode

</param>

</result>

</action>

【struts2中action实现ModelDriven后无法返回json的解决方法】相关文章:

分享JSP中文乱码解决方法

JSP 多条SQL语句同时执行的方法

java使用smartupload组件实现文件上传的方法

java使用smartupload组件实现文件上传的方法

jsp下显示中文文件名及绝对路径下的图片解决方法

jsp和servlet操作mysql中文乱码问题的解决办法

frameset布局时frame中src路径的页面没有加载的解决方法

jsp中Action使用session方法实例分析

struts+spring实现的登陆实例源码

jsp页面传参乱码的解决方法

精品推荐
分类导航