zoukankan      html  css  js  c++  java
  • Spring MVC 异常控制

    1. application.xml

      

     <bean id="exceptionHandler" class="com.xing.handler.MyExceptionHandler"></bean>

    2.package handler Class ...

     1 public class MyExceptionHandler implements HandlerExceptionResolver {
     2     @Override
     3     public ModelAndView resolveException
                (  
                   HttpServletRequest httpServletRequest,
                   HttpServletResponse httpServletResponse,
                   Object o,
                  Exception e
                )
        

        {
    4 e.printStackTrace(); 5 ModelAndView modelAndView = new ModelAndView(); 6 modelAndView.setViewName("../error.jsp"); 7 modelAndView.addObject("msg","真的,没骗你"); 8 return modelAndView; 9 } 10 }

    3.error.jsp

     1 <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
     2 <html>
     3 <head>
     4     <title>Title</title>
     5 </head>
     6 <body>
     7     出错了,服务器被修空调的偷走了
     8 
     9     ${msg}
    10 </body>
    11 </html>
  • 相关阅读:
    题解-Quantifier Question
    题解-[WC2011]最大XOR和路径
    笔记-Recursive Queries
    树套树
    SG函数
    题解-Magic Ship
    分块
    文章根据时间段显示的微信名和微信号
    jquery 在页面上根据ID定位(jQuery锚点跳转及相关操作) 经典
    nginx配置反向代理
  • 原文地址:https://www.cnblogs.com/iscurry/p/11866983.html
Copyright © 2011-2022 走看看