81,092
社区成员
发帖
与我相关
我的任务
分享
@ModelAttribute
private void setReqAndResp(Model model)
{
this.model = model;
Initialize();
}
@Pointcut("execution(* com.rbm.eds.action..*(..))"
+ "&& @annotation(com.rbm.eds.framework.core.annotation.Ajax)")
public void ajaxResponse(){}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Around("ajaxResponse()")
@ResponseBody
public Object afterReturn(ProceedingJoinPoint jp)
{
BaseResponse resp = new BaseResponse();
try {
Object data = jp.proceed();
resp.setCode(1);
if(data != null && (data.toString().startsWith("{")
|| data.toString().startsWith("[")))
{
resp.setData(JSON.parse(data.toString()));
} else
resp.setData(data);
resp.setMessage("请求成功");
} catch(ServiceException ex)
{
resp.setCode(980);
resp.setMessage(ex.getMessage());
}
catch (Throwable e) {
resp.setCode(900);
resp.setMessage("系统错误!请联系管理员");
e.printStackTrace();
logger.error("系统错误", e);
}
return JSON.toJSONString(resp);
}
<mvc:annotation-driven enable-matrix-variables="true">
<mvc:message-converters>
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"></bean>
</mvc:message-converters>
</mvc:annotation-driven>
虽然没有正面解决你的问题,但用这种方式或许能侧面解决