handler

Spring MVC

天涯浪子 提交于 2019-12-24 07:04:53
1.Spring MVC的基本架构 2.组件说明: 以下组件通常使用框架提供实现: DispatcherServlet:前端控制器 用户请求到达前端控制器,它就相当于mvc模式中的c,dispatcherServlet是整个流程控制的中心,由它调用其它组件处理用户的请求,dispatcherServlet的存在降低了组件之间的耦合性。 HandlerMapping:处理器映射器 HandlerMapping负责根据用户请求url找到Handler即处理器,springmvc提供了不同的映射器实现不同的映射方式,例如:配置文件方式,实现接口方式,注解方式等。 Handler:处理器 Handler 是继DispatcherServlet前端控制器的后端控制器,在DispatcherServlet的控制下Handler对具体的用户请求进行处理。 由于Handler涉及到具体的用户业务请求,所以一般情况需要程序员根据业务需求开发Handler。 HandlAdapter:处理器适配器 通过HandlerAdapter对处理器进行执行,这是适配器模式的应用,通过扩展适配器可以对更多类型的处理器进行执行。 ViewResolver:视图解析器 View Resolver负责将处理结果生成View视图,View Resolver首先根据逻辑视图名解析成物理视图名即具体的页面地址

nginx master工作循环

微笑、不失礼 提交于 2019-12-24 06:49:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 默认情况下,nginx使用的是master-worker工作模式接收命令行指令和处理客户端请求。在nginx启动master进程后,其会进行整个nginx工作环境的初始化,然后会依次启动worker进程、cache manager和cache loader进程,接着会进入一个工作循环中,以等待命令行发送来的指令,从而实现对nginx的管理工作。本文主要讲解nginx是如何进行信号的初始化和处理的。 1. 信号处理方法 在介绍nginx是如何组织信号之前,我们首先需要理解的是对信号进行管理的几个主要的方法: 方法 参数 作用 sigaction(int signo, conststruct *act, struct sigaction * oldact); signo指定了当前需要监听的信号类型;act指定了处理当前信号的方法;oldact将接收原先设置的处理信号的方法; 对于signo指定的信号,为其设置接收到该信号时的处理方法 sigemptyset(sigset_t *set) set中存储了当前进程正在监听的信号集 将指定信号集中的信号清空 sigaddset(sigset_t *set, int signo) set为目标信号集;signo为将要添加的信号 将指定信号添加到目标信号集中

How to handle exception using Timer (Thread) class

筅森魡賤 提交于 2019-12-24 05:38:47
问题 I'm trying to handle the Timer 's exception. It would be nice if the class had something like HandlerExceptionEvent so that we could add some event to log something or stop the timer. PS: I don't want to add a try / catch block inside ElapsedEventHandler() . class Program { static void Main(string[] args) { System.Timers.Timer t = new System.Timers.Timer(1000); t.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed); t.Start(); System.Threading.Thread.Sleep(10000); t.Stop(); Console

python自动化测试学习笔记-9python的日志模块

孤者浪人 提交于 2019-12-24 04:09:29
参考 logging模块,用来处理python中的日志; import logginglogging.debug('debug')logging.info('info')logging.warning('warning')logging.error('error')logging.critical('critical') 执行查看结果: 可见,默认情况下python的logging模块将日志打印到了标准输出中,且只显示了大于等于WARNING级别的日志,这说明默认的日志级别设置为WARNING(日志级别等级CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET),默认的日志格式为日志级别:Logger名称:用户输出消息。 import logginglogging.basicConfig(level=logging.DEBUG,filename='2018log.log',filemode='a',format='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s')logging.debug('我的debug信息')logging.info('我的info信息')logging.warning('我的warning信息')logging

Cross-platform custom protocol handler tool

为君一笑 提交于 2019-12-24 02:55:16
问题 I'd like my application to be opened whenever a URL of the form appname://some/url/here is opened on Windows, Mac OSX and Ubuntu Linux. There are of course platform specific ways to achieve this but is there a single (say, Python) tool that would accomplish this with minimal fuss? 来源: https://stackoverflow.com/questions/19401424/cross-platform-custom-protocol-handler-tool

使用spring利用HandlerExceptionResolver实现全局异常捕获

落花浮王杯 提交于 2019-12-24 02:45:42
最近一直没有时间更新是因为一直在更新自己使用的框架。 之后会慢慢带来对之前使用的spring+mvc+mybatis的优化。 会使用一些新的特性,实现一些新的功能。 我会尽量分离业务,封装好再拿出来。 这次带来的是全局异常捕获。 PS:使用的是spring4.3.7版本 PPPPS:当前使用的全局异常捕获方式已更新,不再使用当前博文描述的方式,详细请参考: http://www.cnblogs.com/linkstar/p/8520027.html 实现的功能 首先描述实现的功能:因为在项目中,我们不可否认的会出现异常,而且这些异常并没有进行捕获。经常出现的bug如空指针异常等等。 在之前的项目中,如果我们没有进行任何配置,那么容器会自动打印错误的信息,如果tomcat的404页面,400页面等等。 如果我们在web.xml中进行如下配置,就会拦截错误,然后跳转到指定的错误页面。 <error-page> <error-code>500</error-code> <location>/500.jsp</location> </error-page> 但是这已经落后了,现在我们通过实现spring的HandlerExceptionResolver接口来捕获所有的异常。 如何实现 1、新建GlobalExceptionResolver如下 /** * 全局异常捕获 * @author

Netty 实现HTTP文件服务器

亡梦爱人 提交于 2019-12-24 02:12:30
一,需求 文件服务器使用HTTP协议对外提供服务。用户通过浏览器访问文件服务器,首先对URL进行检查,若失败返回403错误;若通过校验,以链接的方式打开当前目录,每个目录或文件都以超链接的形式展现,可递归访问,并下载文件。 二,关键实现代码 ①文件服务器启动类 需要添加的通道处理器如下: @Override protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("http-decoder", new HttpRequestDecoder()); ch.pipeline().addLast("http-aggregator", new HttpObjectAggregator(65536)); ch.pipeline().addLast("http-encoder", new HttpResponseEncoder()); ch.pipeline().addLast("http-chunked", new ChunkedWriteHandler()); ch.pipeline().addLast("fileServerHandler", new HttpFileServerHandler(url)); } 1) HttpRequestDecoder Decodes {

stm32启动文件分析

一个人想着一个人 提交于 2019-12-24 02:02:39
这篇文章主要是分析stm32启动文件,启动文件是由汇编编写的,文件名为startup_stm32f40_41xxx.s。 启动文件做的工作: 启动文件最主要的功能就是初始化堆栈指针sp,执行复位程序进入C语言main函数 1.初始化堆栈空间大小,定义栈顶位置、堆起始位置等等 2.定义中断向量表,初始化sp指针 3.Reset_Handler复位函数定义 4.配置系统时钟,进入main函数 具体代码分析 Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp 在MDK帮助文档中可以查到EQU是宏定义的伪指令,它的作用就相当于C语言中的define,首先定义栈大小为1KB(0x00000400)。 栈的作用主要保存函数中的局部变量,函数调用过程中的形参,返回地址,因此在函数中如果有较多的局部变量,大型数组最好不要放在函数中定义,在这种情况下就要考虑栈大小是否充足,如果栈溢出了,那程序会出现跑飞,找不到返回地址。 AREA是告诉编译器汇编一个代码段或者数据段,STACK 表示段名,这个可以任意命名; NOINIT 表示不初始化; READWRITE 表示可读可写, ALIGN=3,表示按照 2^3对齐,即 8 字节对齐。

Get remaining time when using handler.postDelayed

风格不统一 提交于 2019-12-24 01:48:18
问题 I am using handler.postDelayed method to create some delay for some animation stuff. Like this: Handler h = new Handler(); h.postDelayed(new Runnable() { @Override public void run() { // Start Animation. } }, 6000); Later, How can I get the remaining time until the animation starts? 回答1: You can simply save the time in a var when you call post delayed long startTime = System.nanoTime(); h.postDelayed(... and then when you need to check the remaining time you can calculate the elapsed time

Get what parameter from Handler.obtainMessage()

北慕城南 提交于 2019-12-24 00:26:43
问题 I am using a Thread to do some BT tasks. I am trying to send a message to the UI thread so I can do UI work based on my BT thread. To do this I am using a Handler, but I don't know how to retrive the data that I send to my Handler. To send data i use: handler.obtainMessage(intCode).sendToTarget(); Where intCode is an int. My Handler looks like this. Handler handler = new Handler(){ @Override public void handleMessage(Message msg){ Bundle data = msg.getData(); int code = data.getInt("what");