springboot-自定义异常处理器
Posted 栗常云
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot-自定义异常处理器相关的知识,希望对你有一定的参考价值。
@Order(-1000)
public class LocalExceptionResolver implements HandlerExceptionResolver {
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) {
return new ModelAndView();
}
private void responseResult(HttpServletResponse response, AppData result) {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-type", "application/json;charset=UTF-8");
response.setStatus(200);
try {
response.getWriter().write(JSON.toJSONString(result));
} catch (IOException ex) {
}
}
}
以上是关于springboot-自定义异常处理器的主要内容,如果未能解决你的问题,请参考以下文章