我正在为我的控制器创建一个日志管理器,用于记录其中的每个操作并返回值
我的控制器是这样定义的:
@Controller
@RequestMapping(value="/ajax/user")
public class UserController extends AbstractController{
@RequestMapping(value="/signup")
public @ResponseBody ActionResponse signup(@Valid SignupModel sign) {
ActionResponse response=new ActionRespone();
response.setMessage("This is a test message");
return response;
}
}
我定义了一个 HandlerInterceptor 来记录每个处理程序的输出:
@Component
public class ControllerInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
return true;
}
public void postHandle(
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
throws Exception {
LogManager log=new LogManager();
log.setMessage();//I need returned ActionResponse here
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}
我在哪里使用 log.setMessage(); 我需要从注册方法返回的 ActionResponse 消息(这是一条测试消息)
我怎样才能做到这一点?