Exception Handling – part 2 – Globally

In our previous article we have seen how to handle exception that are thrown from our controller class,but with that approach,the exceptions can be handle only in that particular controller class and if any other controller class throws the same exception than it will not be handled and user will…

Continue reading

Exception Handling – part 1

The Spring framework provides an annotation @ExceptionHandler that can be used to intercept uncaught/unhandled exceptions in request mapped functions in controllers. When a user hits a url one of the request handling method of the controller class handle it and process it,but if while processing due to some reason it…

Continue reading

Interceptors – part 1

Interceptor in Spring Framework: Spring Interceptors has the ability to pre-handle and post-handle the web requests. Each interceptor class should extend the HandlerInterceptorAdapter class. Here we will create an Interceptor by extending the HandlerInterceptorAdapter class. You can override any of the three callback methods preHandle(), postHandle() and afterCompletion(). As the…

Continue reading

Form Validation – part 4 (using annotation @Pattern, @Past, @Max etc)

Using annotation @Pattern Suppose we have a requirement where we want that user should be able to enter only alphabets in the field having input type=”text” This can be achieved by adding @Pattern(regexp=”[^0-9]*”) annotation for the field for which we want to restrict the user.(Eg- studentName ) @Pattern(regexp=”[^0-9]*”) private String studentName; Next add…

Continue reading

Form Validation – part 1 ( using JSR 303_349 annotations )

Using @Validate and @Size annotation for validation In Spring MVC to perform Validation we have to use a Third Party Library for this purpose. The most commonly used Jars used in Spring are from Hibernate. You can get these files downloaded from below location. http://hibernate.org/validator/downloads/ After you download add below jars…

Continue reading

Custom Property Editor

Custom Property Editor Similar posts: @PathVariable annotation in Spring MVC Handling an HTML form using @RequestParam annotation @ModelAttribute Annotation -part 1 @ModelAttribute Annotation -part 2 @InitBinder annotation, WebDataBinder, CustomDateEditor

Continue reading