赞
踩
浏览器发送请求 localhost:8080/home
通过thymeleaf (xmlns:th=“http://thymeleaf.org”>)和model.addAttribute实现 服务器和网页的连接
通过userDao里面的jdbcTemplate的方法实现服务器和数据库的操作
spring MVC 其实是通过服务器作为中介实现页面和数据库的数据交互
层级结构
首先配置pom(导入jar包)
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> //spring boot 的父类 <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.tl</groupId> <artifactId>idea_demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>idea_demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools rebushu--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> <!--兼容老版本--> <dependency> <groupId>net.sourceforge.nekohtml</groupId> <artifactId>nekohtml</artifactId> <version>1.9.22</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java 数据库--> <dependency> <groupId>mysql</groupId> <artifactId>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。