HTTP Status 400 -
type Status report
message
description The request sent by the client was syntactically incorrect ().
Apache Tomcat/7.0.27
自从使用spring mvc框架后,就频繁遭遇这个问题。刚开始一般都是表单的name字段和Controller里的参数名不匹配,这个时候逐个排查改吧改吧就可以搞定。但是今天逐个参数排查了几遍,发现根参数名无关。
把项目的日志就别降到最低的DEBUG级别,重新发出请求。这才找到了真凶。
2016-01-28 10:41:20,869 [ 19027] DEBUG - efaultHandlerExceptionResolver - Resolving exception from handler [public java.lang.String com.jd.im.king.tracker.web.controller.ClientLocateController.addRule(org.springframework.ui.Model,com.jd.im.king.tracker.domain.route.rule.TrackerClient)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errors
Field error in object 'trackerClient' on field 'tcp_list': rejected value []; codes [methodInvocation.trackerClient.tcp_list,methodInvocation.tcp_list,methodInvocation.java.lang.String,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [trackerClient.tcp_list,tcp_list]; arguments []; default message [tcp_list]]; default message [Property 'tcp_list' threw exception; nested exception is com.alibaba.fastjson.JSONException: exepct '[', but EOF]
Field error in object 'trackerClient' on field 'web_list': rejected value []; codes [methodInvocation.trackerClient.web_list,methodInvocation.web_list,methodInvocation.java.lang.String,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [trackerClient.web_list,web_list]; arguments []; default message [web_list]]; default message [Property 'web_list' threw exception; nested exception is com.alibaba.fastjson.JSONException: exepct '[', but EOF]
2016-01-28 10:41:20,869 [ 19027] DEBUG - .web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'appServlet': assuming HandlerAdapter completed request handling
2016-01-28 10:41:20,869 [ 19027] DEBUG - .web.servlet.DispatcherServlet - Successfully completed request
原来参数名确实没有任何问题,表单参数在转java对象发生了错误。spring把异常作为debug级别打出来了。如此重要的日志信息,不应该打error级别吗?