2017-01-05 12 views
0

私はSpringMvcアプリケーションのテストを書いています。問題が発生しました。ここでSpringMVCテストポストメソッド(パラメータあり)

は、試験のための私の制御方法であって、ここで

@RequestMapping(value = "submit", method = RequestMethod.POST, params = "delete") 
public String delete(@ModelAttribute("inputBean") InputBean inputBean) { 
    Book book = (Book) itemServiceController.getItemFindByIdService().findById(inputBean.getId()); 
    Author author = getAuthorOfBook(book); 
    author.getBookList().remove(book); 
    authorServiceController.getAuthorCreateService().create(authorServiceController.getAuthorUpdateService().update(author)); 
    itemServiceController.getItemDeleteService().delete(inputBean.getId()); 
    return "redirect:index.html"; 
} 

は私mockMvcある:

mockMvc.perform(post("/submit?delete") 
      .contentType(MediaType.APPLICATION_FORM_URLENCODED) 
      .param("id", "1") 
      .sessionAttr("inputBean", new InputBean()) 
      ) 
    .andExpect(status().isOk()) 
    .andExpect(view().name("indexLib")) 
    .andExpect(model().attribute("inputBean", hasProperty("id", is(1)))); 

これはステータスHTTPステータス400

コントローラメソッドは4の1のために作られて返しますフォーム送信ボタン。これを修正するには?私は答えを見つけた

+0

する必要がありますあなたが得る実際の例外とは何ですか? – hakamairi

答えて

0

、適切なURLが

"/submit?id=102&delete=" 
関連する問題