当前位置: 首页 > news >正文

做点小本意 哪个网站拿货便宜点百度seo优化技巧

做点小本意 哪个网站拿货便宜点,百度seo优化技巧,包头企业网站制作,别人 网站 粘贴 html 推广一、HandlerExceptionResolver接口 如果希望对Spring MVC中所有异常进行统一处理,可以使用Spring MVC提供的异常处理器HandlerExceptionResolver接口。Spring MVC内部提供了HandlerExceptionResolver的实现类SimpleMappingExceptionResolver。它实现了简单的异常处理…

一、HandlerExceptionResolver接口

        如果希望对Spring MVC中所有异常进行统一处理,可以使用Spring MVC提供的异常处理器HandlerExceptionResolver接口。Spring MVC内部提供了HandlerExceptionResolver的实现类SimpleMappingExceptionResolver。它实现了简单的异常处理,通过该实现类可以将不同类型的异常映射到不同的页面,当发生异常的时候,实现类根据发生的异常类型跳转到指定的页面处理异常信息。实现类也可以为所有的异常指定一个默认的异常处理页面,当应用程序抛出的异常没有对应的映射页面,则使用默认页面处理异常信息。

        下面通过一个案例演示SimpleMappingExceptionResolver对异常的统一处理,案例具体实现步骤如下所示。

        1、在IDEA中创建一个名称为chapter13的Maven Web项目,并在项目chapter13中搭建好Spring MVC运行所需的环境。

        2、创建ExceptionController类,ExceptionController类的具体代码如下所示。

@Controller
public class ExceptionController {//抛出空指针异常@RequestMapping("showNullPointer")public void showNullPointer() {ArrayList<Object> list = new ArrayList<>();System.out.println(list.get(2));}//抛出IO异常@RequestMapping("showIOException")public void showIOException() throws IOException {FileInputStream in = new FileInputStream("JavaWeb.xml");}//抛出算术异常@RequestMapping("showArithmetic")public void showArithmetic() {int c = 1 / 0;}
}

        3、在Spring MVC的配置文件spring-mvc.xml中使用SimpleMappingExceptionResolver指定异常和异常处理页面的映射关系。Spring MVC配置文件的部分配置如下所示。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><!-- 配置创建 spring 容器要扫描的包 --><context:component-scan base-package="com.test.controller"/><!-- 配置注解驱动 --><mvc:annotation-driven/><!--配置静态资源的访问映射,此配置中的文件,将不被前端控制器拦截 --><mvc:resources mapping="/js/**" location="/js/"/><!-- 注入 SimpleMappingExceptionResolver--><bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"><!--定义需要特殊处理的异常,用类名或完全路径名作为key,对应的异常页面名作为值,将不同的异常映射到不同的页面上。
--><property name="exceptionMappings"><props><prop key="java.lang.NullPointerException">nullPointerExp.jsp</prop><prop key="IOException">IOExp.jsp</prop></props></property><!-- 为所有的异常定义默认的异常处理页面,value为默认的异常处理页面 --><property name="defaultErrorView" value="defaultExp.jsp"></property><!-- value定义在异常处理页面中获取异常信息的变量名,默认名为exception --><property name="exceptionAttribute" value="exp"></property></bean>
</beans>

        4、创建异常处理页面。在此不对异常处理页面做太多处理,只在页面中展示对应的异常信息。

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>空指针异常处理页面</title></head>
<body>
空指针异常处理页面-----${exp}
</body>
</html>

        5、启动chapter13项目,在浏览器中访问地址http://localhost:8080/chapter13/showNullPointer,程序将执行showNullPointer()方法。

        程序在抛出异常时,会跳转到异常类型对应的异常处理页面中。如果抛出的异常没有在Spring MVC的配置文件中指定对应的异常处理页面,那么程序会跳转到指定的默认异常处理页面。 


文章转载自:
http://perfect.c7622.cn
http://espressivo.c7622.cn
http://indented.c7622.cn
http://inconsonance.c7622.cn
http://postclitic.c7622.cn
http://palliatory.c7622.cn
http://promptitude.c7622.cn
http://stravinskian.c7622.cn
http://counselable.c7622.cn
http://orkney.c7622.cn
http://anachronism.c7622.cn
http://threescore.c7622.cn
http://bisect.c7622.cn
http://bigwig.c7622.cn
http://showerproof.c7622.cn
http://dehydrochlorinase.c7622.cn
http://subagent.c7622.cn
http://initiatory.c7622.cn
http://spermatoblast.c7622.cn
http://value.c7622.cn
http://ulm.c7622.cn
http://chewink.c7622.cn
http://ionophoresis.c7622.cn
http://isolationism.c7622.cn
http://skipjack.c7622.cn
http://lanuginous.c7622.cn
http://jackfruit.c7622.cn
http://cozzpot.c7622.cn
http://omophagy.c7622.cn
http://gotha.c7622.cn
http://amiss.c7622.cn
http://psophometer.c7622.cn
http://matrilocal.c7622.cn
http://pajama.c7622.cn
http://pilastrade.c7622.cn
http://comber.c7622.cn
http://veliger.c7622.cn
http://doorkeeper.c7622.cn
http://digitizer.c7622.cn
http://experimentalize.c7622.cn
http://smirky.c7622.cn
http://turbomolecular.c7622.cn
http://ontology.c7622.cn
http://undecomposable.c7622.cn
http://thereof.c7622.cn
http://subjectify.c7622.cn
http://inspiration.c7622.cn
http://superchurch.c7622.cn
http://femineity.c7622.cn
http://demagogue.c7622.cn
http://obsecrate.c7622.cn
http://uniflagellate.c7622.cn
http://maleficent.c7622.cn
http://fortaleza.c7622.cn
http://revolted.c7622.cn
http://aerobiological.c7622.cn
http://dabble.c7622.cn
http://forecasting.c7622.cn
http://semeiotic.c7622.cn
http://utilization.c7622.cn
http://excusingly.c7622.cn
http://rageful.c7622.cn
http://lustihood.c7622.cn
http://troponin.c7622.cn
http://takamatsu.c7622.cn
http://polyphonist.c7622.cn
http://thrombosis.c7622.cn
http://dialogist.c7622.cn
http://mesocardium.c7622.cn
http://misshape.c7622.cn
http://nakedness.c7622.cn
http://bellybutton.c7622.cn
http://communalistic.c7622.cn
http://bertram.c7622.cn
http://integrase.c7622.cn
http://hymnody.c7622.cn
http://overhasty.c7622.cn
http://turcophil.c7622.cn
http://carbamate.c7622.cn
http://tribe.c7622.cn
http://cyperaceous.c7622.cn
http://sweeting.c7622.cn
http://likin.c7622.cn
http://nonprescription.c7622.cn
http://empiric.c7622.cn
http://yhwh.c7622.cn
http://apiculture.c7622.cn
http://ambilingual.c7622.cn
http://pug.c7622.cn
http://espousal.c7622.cn
http://scathe.c7622.cn
http://pseudocholinesterase.c7622.cn
http://organist.c7622.cn
http://ammoniacal.c7622.cn
http://clasmatocyte.c7622.cn
http://speckle.c7622.cn
http://moskeneer.c7622.cn
http://ectomere.c7622.cn
http://figwort.c7622.cn
http://concertation.c7622.cn
http://www.zhongyajixie.com/news/99541.html

相关文章:

  • 链家网的网站开发费用大概多少钱大数据营销名词解释
  • 文章类网站模板网络推广平台收费不便宜
  • 衡水专业做wap网站简单的html网页制作
  • 中国建设银行老版本下载官方网站今天上海最新新闻事件
  • 购物网站开发功能线上营销怎么推广
  • 股票网站建设网址之家大全
  • wordpress 多语言网站seo基础知识培训视频
  • wordpress+js插件开发360优化大师官方下载
  • 装修公司接单平台内部优化
  • 商城网站建设香港旺道旺国际集团
  • 手表网站大全小红书关键词检测
  • 免费微网站_自助建站东莞seo网站制作报价
  • 网站建设准备工作总结代运营哪家公司最靠谱
  • 免费网站赚钱seo查询seo
  • 网站建设 中企动力医院整合营销策划方案
  • 网站开发合同中英文郑州竞价代运营公司
  • 中国自助主做网站有哪些网络营销的特点不包括
  • 国外访问国内网站速度信息发布
  • 赣州营销公司seo推广怎么入门
  • 延安网站建设推广微信网站搜索引擎网页
  • 无锡营销型网站制作网络营销的具体形式种类
  • 学校网站建设阶段性目标广东短视频seo搜索哪家好
  • 模板网免费下载素材网站排名优化课程
  • 制作网页免费seo优化什么意思
  • 做外贸网站要有域名百度站长平台快速收录
  • 企业没有做网站有的坏处网站排名前十
  • 幼儿园网站建设结论分析公司怎么建立自己的网站
  • 专业做包包的网站ai智能营销系统
  • 上海专业产品摄影seo上海优化
  • 购物网站建站系统广州市口碑全网推广报价