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>
  • 相关阅读:
    搭建VueMint-ui框架
    vue项目创建
    jQuery选择器总结
    位运算
    Hash哈希
    并发编程(六)并发容器
    并发编程(五)AQS
    并发编程(四)显示锁
    Java中的几种代码块
    并发编程(三)原子操作CAS
  • 原文地址:https://www.cnblogs.com/iscurry/p/11866983.html
Copyright © 2011-2022 走看看