天天看點

Spring MVC 報錯 HTTP Status 400 – Bad Request

當你請求參數的類型正确,各種配置也正确時,出現400錯誤,同時控制台報錯Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Integer’; nested exception is java.lang.NumberFormatException: For input string: “XXX”]類似的錯誤,可能是你控制層設定的請求路徑和靜态資源的路徑重名了,

比如:

我的通路的頁面是/user/index.html

而控制層的RequestMapping(“user”)

Spring MVC 報錯 HTTP Status 400 – Bad Request

通路時/user/index.html 時會走servlet 的user請求,可能參數類型就對不上,就會400,

如果對的上估計直接傳回請求的json結果了,