Remember once springboot parameter parsing bug debugging HandlerMethodArgumentResolver

Case description

Chinese front end of horizontal input box ——, to the received back into a&madsh;$mdash

Normal should be displayed like this:

bug debug recording ideas

Initially did not want to debug source software, tried many methods, no solution, no way can only source tracking troubleshoot the problem.
Thinking about the class is to parse the parameters? Add a breakpoint debugging cleared, the problem is not clear in the end is which class. SO, Search
---
begin
Step 1: search: spring 参数解析
results of a lot, after reading a lot of posts, reference blog address
foundHandlerMethodArgumentResolver

There are two functions, which resolveArgumentis responsible for parsing the request parameters assigned controller

//负责解析request中的参数,赋给controller
Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
            NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception;

Step 2:
In HandlerMethodArgumentResolverCompositethe resolveArgumentplace plus a breakpoint, the debugger began tracking
is critical here, a multitude of things from here, and why is there a reference to the top of the blog?

Breakpoints tracking cases:

(1)

(2)InvocableHandlerMethod

(3)

(4)

(5)

(6)

(7)

(8)

(9)

Our concern is remarkin ——, F6 for loop directly to remark

(10)

(11)

(12) At this point, parameter changes

(13)

(14)

(15)

(16)

Finally, the above steps are summed up, the first pass debugging parameters do not know where to change, so there are many ways to enter looked F5,
followed by a method breakpoint a party had finally found After you perform this method the original ——becomes the&madsh

convertedValue = doConvertValue(oldValue, convertedValue, requiredType, editor);

to sum up

这个bug花了一上午才找出原因...
首先是刚刚接手对项目不熟悉,不知道BaseController中有 initBinder配置
再者也是不知从何入手调试,源码调试经验不足
---
花里胡哨各种搜索,试了n多方法,最后才知道谁才是爹

Guess you like

Origin www.cnblogs.com/JQKA/p/12073444.html