-
ネストされたクラスの概要
ネストされたクラス修飾子とタイプクラス説明static classNotEmptyの効率的な実装のために動的なNotEmptyの適用(BaseRecordに@NotEmptyを記載しておき、何らかの条件でそれをactiveにする形)を検討したが、 結果不可であることがわかった。 -
フィールドの概要
フィールド -
コンストラクタの概要
コンストラクタ -
メソッドの概要
修飾子とタイプメソッド説明protected SplibGeneralController<?> org.springframework.web.servlet.ModelAndViewhandleAppException(jp.ecuacion.lib.core.exception.checked.AppException exception, org.springframework.security.core.userdetails.UserDetails loginUser) org.springframework.web.servlet.ModelAndViewhandleAppWarningException(jp.ecuacion.lib.core.exception.checked.AppWarningException exception, org.springframework.security.core.userdetails.UserDetails loginUser) handleHttpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException exception, org.springframework.ui.Model model) org.springframework.web.servlet.ModelAndViewhandleInputValidationException(InputValidationException exception, org.springframework.security.core.userdetails.UserDetails loginUser) 本来はspring mvcのvalidationに任せれば良いのだが、以下の2点が気に入らず、springで持っているerror情報(*)を * 修正しようとしたが「unmodifiablelist」で修正できなかったため、やむなく個別の処理を作成。voidhandleNoResourceFoundException(org.springframework.web.servlet.resource.NoResourceFoundException exception, org.springframework.ui.Model model) HTTP 404。org.springframework.web.servlet.ModelAndViewhandleOptimisticLockingFailureException(OverlappingFileLockException exception, org.springframework.security.core.userdetails.UserDetails loginUser) org.springframework.web.servlet.ModelAndViewhandleThrowable(Throwable exception, org.springframework.ui.Model model) WebでConstraintViolationExceptionが直接上がってくる場面は、事前のチェックが漏れた場合であり、 この場合は単体のConstraintViolationExceptionしか取得できないこともあり正しくないため、実装不備とみなしここに入れることとする。
-
フィールド詳細
-
INFO_FOR_ERROR_HANDLING
- 関連項目:
-
-
コンストラクタの詳細
-
SplibExceptionHandler
public SplibExceptionHandler()
-
-
メソッドの詳細
-
getController
-
handleAppWarningException
@ExceptionHandler(jp.ecuacion.lib.core.exception.checked.AppWarningException.class) public org.springframework.web.servlet.ModelAndView handleAppWarningException(jp.ecuacion.lib.core.exception.checked.AppWarningException exception, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails loginUser) throws Exception - 例外:
Exception
-
handleAppException
@ExceptionHandler(jp.ecuacion.lib.core.exception.checked.AppException.class) public org.springframework.web.servlet.ModelAndView handleAppException(jp.ecuacion.lib.core.exception.checked.AppException exception, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails loginUser) throws Exception - 例外:
Exception
-
handleOptimisticLockingFailureException
@ExceptionHandler(java.nio.channels.OverlappingFileLockException.class) public org.springframework.web.servlet.ModelAndView handleOptimisticLockingFailureException(OverlappingFileLockException exception, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails loginUser) throws Exception - パラメータ:
exception-loginUser-- 戻り値:
- 例外:
Exception
-
handleInputValidationException
@ExceptionHandler(InputValidationException.class) public org.springframework.web.servlet.ModelAndView handleInputValidationException(InputValidationException exception, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails loginUser) throws Exception 本来はspring mvcのvalidationに任せれば良いのだが、以下の2点が気に入らず、springで持っているerror情報(*)を * 修正しようとしたが「unmodifiablelist」で修正できなかったため、やむなく個別の処理を作成。- 画面上部に複数項目のエラー情報をまとめて表示する場合、並び順が実行するたびに変わる
- @Sizeなどのvalidationで、blankを無視する設定になっていないため、 値がblankで、かつblankがエラーのannotationが付加されている場合でも、@Sizeなどのvalidationが走ってしまう。
尚、controller層でのinput validationが漏れた場合、JPAの仕様によりDBアクセス直前にもう一度validationが行われ、 そこでConstraintViolationExceptionが発生する。 そうなる場合は、事前のチェックが漏れた場合のみであり、また単体のConstraintViolationExceptionしか取得できず、 想定しているエラー表示方法(input validation分はまとめて結果を表示)とは異なり正しくない。 そのため実装不備とみなしシステムエラーとする(=本クラス上で特別扱いはせず、"handleThrowable"methodで拾う)。
I(*) このような形でspring mvcのerror情報の取得が可能。最後のprintlnではfieldとcode(validator名:"Size"など)を取得している。// bean validation標準の各種validatorが、""の場合でもSize validatorのエラーが表示されるなどイマイチ。 // 空欄の場合には空欄のエラーのみを出したいので、同一項目で、NotEmptyと別のvalidatorが同時に存在する場合はNotEmpty以外を間引く。 // spring標準のvalidatorは、model内に以下のようなkey名で格納されているのでkey名を前方一致で取得 // org.springframework.validation.BindingResult.driveRecordEditForm String bindingResultKey = getModel().asMap().keySet().stream() .filter(key -> key.startsWith("org.springframework.validation.BindingResult")) .collect(Collectors.toList()).get(0); BeanPropertyBindingResult bindingResult = (BeanPropertyBindingResult) getModel().asMap().get(bindingResultKey); for (FieldError error : bindingResult.getFieldErrors()) { System.out.println(error.getCode()); System.out.println(error.getField()); }
- 例外:
Exception
-
handleHttpRequestMethodNotSupportedException
@ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class) public String handleHttpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException exception, org.springframework.ui.Model model) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException - 例外:
jp.ecuacion.lib.core.exception.checked.BizLogicAppException
-
handleNoResourceFoundException
@ExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException.class) public void handleNoResourceFoundException(org.springframework.web.servlet.resource.NoResourceFoundException exception, org.springframework.ui.Model model) throws org.springframework.web.servlet.resource.NoResourceFoundException HTTP 404。- 例外:
org.springframework.web.servlet.resource.NoResourceFoundException
-
handleThrowable
@ExceptionHandler(java.lang.Throwable.class) public org.springframework.web.servlet.ModelAndView handleThrowable(Throwable exception, org.springframework.ui.Model model) WebでConstraintViolationExceptionが直接上がってくる場面は、事前のチェックが漏れた場合であり、 この場合は単体のConstraintViolationExceptionしか取得できないこともあり正しくないため、実装不備とみなしここに入れることとする。
-