I'm using Bozho solution to create a session attribute annotation under Spring mvc.
I've a problem when the object is not in the session and I've something like
@SessionAttribute(required = false) MyFormObject myFormObject
The annotation is defined as
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SessionAttribute {
String value() default "";
boolean required() default true;
String defaultValue() default ValueConstants.DEFAULT_NONE;
}
I get an exception since defaultValue() returns a String and my custom ArgumentResolver tries to assign this String to MyFormObject.
How can I instruct Spring to assign null to myFormObject instead of ValueConstants.DEFAULT_NONE?