第二章

1.spring工程搭建

创建项目,引入maven依赖

引入maven依赖:

spring的依赖共有以下四个方面:

1。spring核心依赖
spring-core、spring-beans、spring-context

2。spring dao依赖
spring-jdbc、spring-tx

3。spring web依赖
spring-web、spring-webmvc

4。spring test依赖

<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.项目常用后端代码结构

有3层功能划分:Controller层,Service层

,DAO层。

他们的功能是

  1. Dao层去数据库查询基础数据,查到的基础数据用entity实体类存储
  2. Service层调用Dao层方法拿取基础数据加工处理,加工好的数据用vo视图类存储
  3. Controller层调用Service层方法拿取数据给前端

3.if判断和三目运算符

if判断结构:

if (判别式) {
代码块1
} else {
代码块2
}s
三目运算符还有一种比if条件语句更为简单的语句就是三目运算符

结构:

1
判别式 ? 代码块1 : 代码块2;

 

posted @ 2021-03-28 15:43  熊霸  阅读(202)  评论(0)    收藏  举报