M
M
Mararchello2016-05-04 10:37:38
Java
Mararchello, 2016-05-04 10:37:38

How to get object field value with custom annotation?

There is such a class:

public class SomeBean {
    public String email;
}

Using Spring MVC I create a mapped method:
@RequestMapping(value = "hello")
    public String someMethod(SomeBean myBean) {
    // do something
}

The task is this: I need to create my own annotation, with which I will mark the incoming parameter ' myBean ' and extract the value of the email field . Tell me how to do it? With the help of reflection, it is impossible to get a value, as I understand it. How to be in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor Alenkov, 2016-05-04
@Borz

org.springframework.util.ReflectionUtils#getField

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question