git-leon преди 5 години
родител
ревизия
d5ac3273fc
променени са 1 файла, в които са добавени 5 реда и са изтрити 3 реда
  1. 5
    3
      README.md

+ 5
- 3
README.md Целия файл

@@ -532,7 +532,7 @@ We also need a new field in the `ErrorDetail` class to hold errors. There may be
532 532
 ```java
533 533
 @ExceptionHandler(MethodArgumentNotValidException.class)
534 534
 public ResponseEntity<?>
535
-handleValidationError(  MethodArgumentNotValidException manve,
535
+handleValidationError(MethodArgumentNotValidException manve,
536 536
 						HttpServletRequest request){...}
537 537
 ```
538 538
 
@@ -559,6 +559,9 @@ for(FieldError fe : fieldErrors) {
559 559
 }
560 560
 ```
561 561
 
562
+- Use an autowired `MessageSource` object in the `RestExceptionHandler` to set the message on ValidationError objects (ie: `setMessage(messageSource.getMessage(fe,null));` )
563
+  - This object will be autowired (or injected) the same way your `CRUDRepository` instances are.
564
+
562 565
 ## Part 5.7 - Externalize strings in a messages.properties file
563 566
 
564 567
 Commonly used strings in your Java program can be removed from the source code and placed in a separate file. This is called externalizing, and is useful for allowing changes to text displayed without impacting actual program logic. One example of where this is done is in internationalization, the practice of providing multilingual support in an application, allowing users to use an application in their native language.
@@ -568,8 +571,7 @@ There are two steps needed here to externalize and standardize the validation er
568 571
 - Create a `messages.properties` file in the `src/main/resources` directory with the given properties below
569 572
   - `messages.properties` is a key-value file stored in plain text. Your IDE may have a table-based view or show the contents as text
570 573
   - `.properties` files are a common idiom in Java applications; they contain additional information the application uses that doesn't impact the actual source code.
571
-- Use an autowired `MessageSource` object in the `RestExceptionHandler` to set the message on ValidationError objects (ie: `setMessage(messageSource.getMessage(fe,null));` )
572
-  - This object will be autowired (or injected) the same way your `CRUDRepository` instances are.
574
+
573 575
 
574 576
 **`messages.properties` content**:
575 577