我们的控制器看起来像这样-
update_branch
如果我们在请求中未指定必需的参数“ testCode”,则会收到“ 400 Bad Request”,但错误响应的消息部分仍为空白。
我们得到的回应-
update_branch
但预期是-
def dfs(node,visited,te,c=0):
if visited[node]==0:
visited[node]=1
te.append(node)
c=c+1
print(te)
if node in king:
for nei in king[node]:
if visited[nei]==0:
dfs(nei,visited,te,c)
我们正在使用以下Spring依赖项-
@RestController
@RequestMapping(value="api")
@Validated
public class SampleController {
@RequestMapping(value = {"/test"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public void test(
@RequestParam(value = "testCode",required=true) String merchantCode
) throws Exception{
System.out.print("This is Test");
}
}
为此,我们看到了MissingServletRequestParameterException,但是在例外情况下,消息以blank(“”)的形式出现。
答案 0 :(得分:1)
我刚刚用server.error.include-message=always
更新了bootstrap.yml。从Spring 2.3.0看来,Spring的默认行为已更改。我们可以从更多详细信息中引用以下链接https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#changes-to-the-default-error-pages-content
答案 1 :(得分:0)
application.yml 中的配置
server:
error:
include-message: always
include-binding-errors: always
include-stacktrace: on_trace_param
include-exception: true