As you know @RequestMapping
get used to intercept a HttpServletRequest
.
I want to know how @Controller @RequestMapping
together can bind a request coming from a client to a specific method inside a java class ?
I want to write a similar java application to do the same functionality, Imagine We have a class like this:
@Actor
public class JavaForever {
@Department(value="IT")
public void departmentIT(){...}
@Department(value="Physic")
public void departmentPhysic(){...}
}
And a StudentBean class :
public class StudentBean {
private String department;
private Integer age;
//Other class variable
//Getters & Setters
}
and finally we have a Test class like this:
public class TestApplication {
//getStudentFromDatabaseMethod() implementation here
public static void main(String[] agrs){
List<StudentBean> allStudents = new TestApplication().getStudentFromDatabaseMethod();
//other codes
}
}
As you see getStudentFromDatabaseMethod()
returns List< StudentBean>
, now the question is how we can force this method to get intercept with our @Department
annotation which resides in JavaForever
class before
it returns any value ...
how we can do this ???
Here is a broad overview
Summary:
Start by reading an Annotation Tutorial. You will need to scan your classes (during startup) for your annotations (using reflection) then handle them appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With