web主流开发程序:servlet,PHP,net
原生Servlet构建MVC的缺点:
1、存在安全隐患的问题
2、数量增加,产生更大的压力
响应流程:客户端游览器由控制器到模型到数据库返回模型在由控制器转到视图在由控制器返还客户
优势:各守其职、互不影响;低生命周期;方便维护;视图可以共享一个模型;
Struts2是基于MVC的表现层框架
缺点:安全低;检验频繁,出错返回不同;传递时麻烦
SpringMVC:是Spring生态圈中的web-mva框架,是spring生态圈的一部分。
MVC:代表模型视图和控制视图
模型:处理数据
视图:处理显示
控制器:控制整个逻辑
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-expression -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jcl -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jcl</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
</dependencies>
2.
后端代码的结构Controller层(流程控制层)负责流程控制+Service层(业务逻辑层)负责逻辑应用设计+Dao层(数据操作层)负责与数据库联络+常用的entity实现类和vo视图类。
3.
if (判别式) {
代码块1
} else {
代码块2
}
public class Test {
public static Integer getMaxIf(int a, int b) {
if (a > b) {
return a;
} else {
return b;
}
} public static void main(String[] args) {
int a = 1;
int b = 2;
System.out.println("if 返回最大值" + getMaxIf(a, b));
}
}