2014-03-27 6 views
0

양식을 제출하려고 할 때 tomcat이 "클라이언트가 보낸 요청이 구문 상 올바르지 않습니다." 이것은 jsp 양식입니다. 도와주세요.JSP 형식의 잘못된 요청

<form:form method="POST" commandName="articleDTO" id="categoryForm"> 
    <form:errors path="*" /> 
    <td>Title</td> 
    <td><form:input path="title" /></td> 

    <table> 
     <thead> 
      <tr> 
       <th>Category</th> 
       <th></th> 
      </tr> 
     </thead> 
     <c:forEach items="${articleDTO.categories}" var="Category" 
      varStatus="i" begin="0"> 
      <td><form:select path="categories[${i.index}]"> 
        <form:option value="NONE" label="--- Select ---" /> 
        <form:options items="${categoryList}" /> 
       </form:select></td> 
     </c:forEach> 
    </table> 
    <td colspan="3"><input type="submit" value="GG" /></td> 
</form:form> 

Conroller :

@RequestMapping(method = RequestMethod.GET) 
public ModelAndView getAdminPage() { 
    return new ModelAndView("admin_page").addObject("categoryList", 
      categoryService.getAllCategories()).addObject("articleDTO", new ArticleDTO()); 
} 

@RequestMapping(method = RequestMethod.POST) 
public ModelAndView ondas(ArticleDTO articleDTO) { 
    return new ModelAndView("done").addObject("article", articleDTO); 
} 

DTO :

private String title; 

@NotEmpty 
@Range(min = 100, max = 6000) 
private String description; 

@NotEmpty 
private List<Category> categories = new ArrayList<Category>(); 

public ArticleDTO() { 
    Category category = new Category(); 
    category.setTitle("news"); 
    category.setId(1L); 
    Category category1 = new Category(); 
    category1.setTitle("news1"); 
    category1.setId(2L); 
    categories.add(category1); 
    categories.add(category); 
} 

나는 기사 범주의 사용자 목록에서 얻을하려고 해요

+0

로그를 DEBUG로 설정하십시오. 그들은 틀린 것을 당신에게 말할 것이고 당신은 그것을 여기에 게시 할 수 있습니다. –

답변

0

나는 당신의 POST 데 거의 확신 유효성 검사 문제 ... :)

방법을 다음과 같이 변경하십시오.

@RequestMapping(method = RequestMethod.POST) 
public ModelAndView ondas(ArticleDTO articleDTO, BindingResult result) { 

    if (result.hasErrors()) { 
     return new ModelAndView("admin_page").addObject("categoryList", 
     categoryService.getAllCategories()).addObject("articleDTO", new ArticleDTO()); 
    } 
    return new ModelAndView("done").addObject("article", articleDTO); 
} 
관련 문제