|
復制代碼 代碼如下:
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>
jsp技術:struts2中action實現(xiàn)ModelDriven后無法返回json的解決方法,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。