Spring v1.5.14で開発しているのですが、validationMessageのフィールド名が置換されるタイミングがわかりません。
BindingResult errorsには「{0}は必須です。」というエラーメッセージが入ってるのですが、
これが「名前は必須です。」になる時のタイミングが良くわかりません。
フィールド名を置換したメッセージは取得できないのでしょうか?
Java
1@Data 2public class HogeForm { 3 @NotEmpty(message = "{hogemsg}") 4 private String name; 5} 6 7@Controller 8@RequestMapping("/hoge") 9public class HogeController { 10 @RequestMapping(value="/updateCheck", method = RequestMethod.POST) 11 @ResponseBody 12 public HashMap<String, String> updateCheck( 13 Model model 14 , @Validated HogeForm form 15 , BindingResult errors 16 , RedirectAttributes attributes 17 , HttpServletRequest request) throws Exception { 18 return hogeService.checkUpdate(form, errors);←ここの処理で置換されたメッセージを丸々取り出したい 19 }
validationMessage.propertiesは以下を設定しています。
hogemsg={0}は必須です。 name=名前
これは試されましたか?https://qiita.com/neriudon/items/4329c80e676362c62f28
hogeService をしらないひとに答えろと?
あなたの回答
tips
プレビュー