1. 程式人生 > >The request sent by the client was syntactically incorrect.(轉載)

The request sent by the client was syntactically incorrect.(轉載)

gif div button btn brief submit label rect method

這個錯誤是SpringMVC報出來的,見到它意味著html/jsp頁面的控件名稱 和 controller裏函數的參數不符。

技術分享

好比界面有個這樣的form

技術分享
    <form name="form1" action="uploadDocument.html" method="post" ENCTYPE="multipart/form-data">
    <div class="form" >
            <p>
                <span class="req"><input id="remarkTxt"  name="remarkTxt
" class="field size4" title="Enter the date" /></span> <label>Remark: <span>(The brief introduction of the file)</span></label> </p> <p> <span class="req"><input type="file" name="uploadFileCtrl
" class="field size4" title="Choose the file" /></span> <label>Upload file: <span>(Click browse to choose)</span></label> </p> </div> <div class="buttons"> <input id="queryBtn" type="button" class="button" value="Submit" /> </div> </form>
技術分享

而對應的函數參數應該這樣寫:

技術分享
@RequestMapping(value="/uploadDocument")
    public String uploadDocument( @RequestParam("remarkTxt") String remark, 
                                  @RequestParam("uploadFileCtrl") MultipartFile file,
HttpServletRequest request,
HttpServletResponse response){
....
}
}
技術分享

註意上述粗體字的一一對應關系。

分類: Spring,Java Web應用開發

The request sent by the client was syntactically incorrect.(轉載)