BindingResult objects are a great way to use Java Bean Validation within your forms. This post will teach you how to process the form within a separate action that you present it and be able to forward the BindingResult back to the form action in case of an error so that the errors can be displayed. The following code snippet represents two controller actions, one to present the form and another to process it.
Bean Validation (JSR303) is a great way to verify that you receive valid data from all sorts of input. You have several baked in options such as @NotNull and @Min. However you will invariably come across the need to implement your own annotation for some custom validation. The following classes accomplish this task:
There are posts out there that help you serve up files using Spring MVC. A few of these instruct to serve down a byte array by using something like Files.readAllBytes(path); This works great for small files but keep in mind that doing this reads the entire file into memory, which can definitely cause problems on files of any sort of size. The following example will show you how to serve down large files one chunk at a time.
The other day I ran into a situation where I needed to use a CASE statement in both the SELECT statement as well as the GROUP BY statement in an HQL (Hibernate Query Language) string.
It is possible to accomplish this with some special syntax. This particular example is useful to group and count dated objects by the quarter of the year in which they were created.
If you want to customize the url that users are sent to after a failed login attempt when you are using the Spring Security Core plugin they have exposed this configuration string. Simple add this in your Config.groovy file: