Unable to find resource

场景:
配合JS调试时,出现上面的异常,且数据可以正常接收,程序内容正常执行完毕,但断点离开return SUCCESS; 后报错

原因:
AJAX请求,需要接收JAVA端接口的返回值;
项目是SSM 架构模式,return success 则会跳转到新的页面,则当前的AJAX无响应

解决:
AJAX请求的接口不需要返回值,void即可,通过返回JSON串的数据格式

JSONObject jsonObject=JSONObject.fromObject(map);
String result=jsonObject.toString();        
PrintWriter writer=response.getWriter();
writer.write(callbackparam+"("+result+")");


异常代码:

@Action(value = "editScheduleTracking", results = { @Result(name = SUCCESS, type = ResultTypeConstants.JSON) })
public String editScheduleTracking(){
schedule = ServiceUtil.scheduleTrackingService.selectScheduleTracking(merchant.getId());
JSONObject json = new JSONObject();
json.put("schedule", schedule);
output(json);
return SUCCESS ;
}


JSON传值,不需要程序跳转,而是由JS来控制

解决:

将 return SUCCESS ; 改为 return null ;


猜你喜欢

转载自mingyundezuoan.iteye.com/blog/2210922