Category: Java
-
PropertyEditors in Spring 3
PropertyEditor is an interface that provides a support for the conversion of the value of a property (usually of type String) in an object that can be Date, URL, etc.
-
Overriding the equals() and hashCode() methods
The equals() method is inherited from the superclass Object and determines if two instances are equal or equivalent. Usually this method should be overridden because the equals() method of the Object class is equivalent to the operator ==, which returns true if and only if the two references refer to the same object.
-
Executing code on the creation or destruction of a bean in Spring
There are 3 ways to execute code to create a bean in Spring: with the annotation @PostConstruct implementing the interface InitializingBean configuring the property init-method The reason why you run code when you create a bean is often to check the dependencies, and assign a default value, or automated actions such as starting a scheduled…
-
Basic configuration of Spring Security 3 and MySQL
In this post I explain how to implement Spring Security in a web application, as I did in a previous post but the authenticated user’s username and password are not saved to a file .xml but in a MySQL database. As in the previous post, I configure one user only trying to access index.html and…
-
Basic configuration of Spring Security 3
In this post I write about a basic configuration of Spring Security 3, the Spring framework for authentication and authorization of the users. In this example there is only one user trying to access to index.html and he is redirected to the standard login page for authentication. In this project I use and configure maven…
-
How to access to the members of outer class from inner class
You can’t access to the members of an outer class from an inner class using the keyword “this”. In fact, the keyword “this” in an inner class is a reference to the inner class itself. To have a reference to the outer class, you must use the syntax: [OuterClassName].this where [OuterClassName] is the name of…
-
The access modifiers of methods and variables of a java class
In this article I explain how to set the visibility of methods and instance variables, ie those variables declared outside of any method (the variables declared within a method are called local variables and they are visible in the method only).