spring2.0 그리고 multiactioncontroller환경일때 수동으로 validation하는방법
in controller...
in controller...
public ModelAndView makePost(HttpServletRequest request,HttpServletResponse response) throws Exception{
Map model = new HashMap();
MakeCommand command = new MakeCommand();
bind(request, command);
BindingResult result = new BeanPropertyBindingResult( command, "command");
result.addError(new FieldError("row", "api_name", command.getApi_name(), false,null,null,"이름을 입력하세요"));
//수동으로 BindingResult 추가
model.put("org.springframework.validation.BindingResult.command",result);
if(result.hasErrors()){
model.put("command",command);
return new ModelAndView("apis/make",model);
}
return new ModelAndView("apis/make",model);
}
in jsp...
<form:form action="${ctx }/apis/makePost.htm" method="post" commandName="command" >
api name
<form:input path="api_name" />
<form:errors path="api_name" />
<input type="submit" value="save" />
</form:form>
댓글