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

网站怎么做域名解析手机如何制作ppt

网站怎么做域名解析,手机如何制作ppt,网站升级中,模板建站源码SpringMVC之异常处理 异常分为编译时异常和运行时异常#xff0c;编译时异常我们trycatch捕获#xff0c;捕获后自行处理#xff0c;而运行时异常是不可预期的#xff0c;就需要规范编码来避免#xff0c;在SpringMVC中#xff0c;不管是编译异常还是运行时异常#xff…SpringMVC之异常处理 异常分为编译时异常和运行时异常编译时异常我们trycatch捕获捕获后自行处理而运行时异常是不可预期的就需要规范编码来避免在SpringMVC中不管是编译异常还是运行时异常都可以最终由SpringMVC提供的异常处理器进行统一管理这样就可以避免随时随地捕获异常的繁琐性。   三种处理方式 1.简单异常处理器使用Spring MVC内置的异常处理器处理SimpleMappingExceptionResolver Component public class MysimpleMappingExceton {Beanpublic SimpleMappingExceptionResolver simpleMappingExceptionResolver(){SimpleMappingExceptionResolver simpleMappingExceptionResolver new SimpleMappingExceptionResolver();//默认错误simpleMappingExceptionResolver.setDefaultErrorView(default.html);Properties properties new Properties();properties.setProperty(java.lang.ArithmeticExceotion,erro1.html);properties.setProperty(java.io.FileNotFoundException,erro2.html);simpleMappingExceptionResolver.setExceptionMappings(properties);return simpleMappingExceptionResolver;} } 2.自定义异常处理器实现HandlerExceptionResolver接口自定义异常进行处理 Component public class MyHandlerExceptionResolver implements HandlerExceptionResolver {Overridepublic ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {ModelAndView modelAndView new ModelAndView();modelAndView.setViewName(/default.html);return modelAndView;} } 3.使用ControllerAdviceExceptionHandler实现全局异常 ControllerAdvice public class GloExceotion {ExceptionHandler(RuntimeException.class)ResponseBodypublic Result runtimeException(){Result result new Result(200,错误,new Object());return result;}ExceptionHandler(FileNotFoundException.class)public ModelAndView fileNotException(){ModelAndView modelAndView new ModelAndView();modelAndView.setViewName(/erro2.html);return modelAndView;}ExceptionHandler(Exception.class)public ModelAndView Exception(){ModelAndView modelAndView new ModelAndView();modelAndView.setViewName(/default.html);return modelAndView;} } 例子 RestController public class ExceptionController {RequestMapping(/e1)public String e1 (){int a10/0;return ruuning exception;}RequestMapping(/e2)public String e2() throws FileNotFoundException {FileInputStream fileInputStream new FileInputStream(file:/barch:/);return ruuning exception;}RequestMapping(/e3)public String e3() {int [] array {1,2};System.out.println(array[5]);return ruuning exception;} }
http://www.pierceye.com/news/51371/

相关文章:

  • 学ui设计网站可否用nas做网站
  • 阜阳哪里做网站网站建设费用计入什么会计科目
  • 网站seo关键词排名优化网页设计制作一个网站
  • 班级网站html代码网站seo优化如何做
  • 爱站网工具网页免费游戏
  • 贵金属网站模板快速搭建网站前端插件
  • 河南网站关键词优化wordpress自定义关键词链接文章
  • 网站建设 中企动力东莞后台管理wordpress 提示ftp
  • 网站制作怎么添加图片山西中色十二冶金建设有限公司网站
  • 网站开发人员上级主管互联网代理商联盟平台
  • 物流网站建设方案权限管理wordpress 多人编辑
  • 做网站网络合同移动互联网开发的前景
  • 佛山网站建设找方维网络餐饮网站建设推广
  • 人和机械网站建设做网站明细范文
  • 月嫂云商城网站建设母婴网站源码
  • 安溪县建设局网站大数据是干什么的
  • 网站建设与管理学的是什么百度手机快速排名点击软件
  • 公司内部网站建设管理办法温州市建设局网站
  • 小型公司网站建设论文建筑人才网怎么和招聘人说话
  • wordpress2018主题seo优化销售话术
  • 深圳seo招聘长尾词排名优化软件
  • 在商用网站上用明星的名字做昵称网站结构优化包括哪些
  • 太原网站制作企业重庆优化网站排名
  • 动漫制作专业学习方法游戏优化大师有用吗
  • 浙江省建设厅干部学校门户网站php简单企业网站源码
  • 如何做内容收费的网站应用公园官网登录页面
  • 河北邢台移动网站建设wordpress注册邮件自定义
  • 桐庐县建设局网站要加强分院网站建设
  • 现在做网站用什么网站图片不是本站的对seo有什么不好
  • 做网站申请域名的流程参考消息电子版在线阅读