http://sishuok.com/forum/blogPost/list/5160.html
1 是什么
1.1 web MVC 设计模式
框架设计思想,将业务逻辑,页面相应控制,客户端请求与数据库处理分离出来,
达到结构清晰明了,使得代码更加容易修改和管理。
M- model
业务逻辑层
V- view
业务展示层
C- controller
控制层,自己想要实现的功能在这里编写一些列的class来实现功能;
1.2 使用java 实现 web MVC 设计模式 的请求驱动类型的轻量级WEB框架
在原来的web c-s(客户与服务器相应模式中,多了controller 和 model,
一般所使用的web 服务器是TOMCAT
http://sishuok.com/forum/blogPost/list/5160.html
2 Spring 框架
2.1 spring 框架的模块
![](https://i-blog.csdnimg.cn/blog_migrate/bd9f89fe670e489f7d4b552a02d2c825.png)
2.2 spring 框架中Model, ModelAndView, ModelMap 等的区别
http://itroop.iteye.com/blog/263845
2.3 Spring 中的反射机制
package myprojcet1;
import java.lang.reflect.Field;
class Student {
String name;
int age;
//无参数构造方法
public Student() {
super();
System.out.println("success!");
}
public Student(String name, int age) {
super();
this.name =name;
this.age = age;
System.out.println("this.age is : "+ this.age);
}
}
public class ReflectNewInstance {
public static void main(String[] args) throws Exception {
Class<Student> clastu1 = Student.class; //获取class对象,field类
Student obj = clastu1.newInstance();
System.out.println(obj);
//使用带参数的构造方法
java.lang.reflect.Constructor<Student> constu1 = clastu1.getConstructor(String.class,int.class);
Student stu1= constu1.newInstance("zhangsan",30);
System.out.println(obj);
Student stu2 = constu1.newInstance("liming",18);
System.out.println(stu2.getClass().equals(stu1.getClass() ));
System.out.println(stu2.getClass().equals(obj.getClass() ));
System.out.println(stu1.name.compareTo(stu2.name) +" is bigger");
System.out.println("stu1.age + stu2.age is "+ stu1.age +""+ stu2.age);
//调用反射定义的一个通用的比较方法,
System.out.println(compare(stu1, stu2).name + " is bigger");
}
public static Student compare(Student stu1, Student stu2) {
try {
Field field = stu1.getClass().getDeclaredField("age");
field = Student.class.getDeclaredField("age");
int val1 = (Integer)field.get(stu1);
int val2 = (Integer)field.get(stu2);
if (val1 > val2){
return stu1;
} else {
return stu2;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
}
http://www.blogjava.net/Todd/archive/2010/04/22/295112.html
Spring MVC 框架的易用之处在于,你可以按任意顺序定义请求处理方法的入参(除了 Errors 和 BindingResult 必须紧跟在命令对象/表单参数后面以外),Spring MVC 会根据反射机制自动将对应的对象通过入参传递给请求处理方法。这种机制让开发者完全可以不依赖 Servlet API 开发控制层的程序,当请求处理方法需要特定的对象时,仅仅需要在参数列表中声明入参即可,不需要考虑如何获取这些对象,Spring MVC 框架就象一个大管家一样“不辞辛苦”地为我们准备好了所需的一切。
https://www.ibm.com/developerworks/cn/java/j-lo-spring25-mvc/