正如您所知道的那样,@RequestMapping
用于拦截 HttpServletRequest
。
我想知道如何使用 @Controller @RequestMapping
将来自客户端的请求绑定到 java 类中的特定方法?
我想编写一个类似的 Java 应用程序以执行相同的功能,假设我们有一个如下所示的类:
@Actor
public class JavaForever {
@Department(value="IT")
public void departmentIT(){...}
@Department(value="Physic")
public void departmentPhysic(){...}
}
下面是一个StudentBean类的示例:
public class StudentBean {
private String department;
private Integer age;
//Other class variable
//Getters & Setters
}
最后,我们有一个像这样的测试类:
public class TestApplication {
//getStudentFromDatabaseMethod() implementation here
public static void main(String[] agrs){
List<StudentBean> allStudents = new TestApplication().getStudentFromDatabaseMethod();
//other codes
}
}
正如您所看到的,getStudentFromDatabaseMethod()
返回 List< StudentBean>
,现在的问题是我们如何强制该方法与我们的 @Department
注释进行拦截,该注释位于 JavaForever
类的 before
方法中,在返回任何值之前...
我们该怎么做???
RequestMappingHandlerMapping
类开始。 - Sotirios Delimanolis@Controller
еӨ„зҗҶзЁӢеәҸж–№жі•дёӯдҪҝз”ЁAOPгҖӮ - Sotirios Delimanolis