当前位置: 首页 > news >正文

建设部二级结构工程师注销网站seo网站建站

建设部二级结构工程师注销网站,seo网站建站,本地网站建设需要什么,做网站容易 但运营难⭐⭐⭐⭐⭐⭐ Github主页👉https://github.com/A-BigTree 笔记链接👉https://github.com/A-BigTree/Code_Learning ⭐⭐⭐⭐⭐⭐ 如果可以,麻烦各位看官顺手点个star~😊 如果文章对你有所帮助,可以点赞👍…

⭐⭐⭐⭐⭐⭐
Github主页👉https://github.com/A-BigTree
笔记链接👉https://github.com/A-BigTree/Code_Learning
⭐⭐⭐⭐⭐⭐

如果可以,麻烦各位看官顺手点个star~😊

如果文章对你有所帮助,可以点赞👍收藏⭐支持一下博主~😆


文章目录

  • 2 传统方式实现增删改查
    • 2.1 准备工作
      • 2.1.1 创建实体类
      • 2.1.2 创建Service
        • 接口
        • 实现类
      • 2.1.3 搭建环境
        • 引入依赖
        • `web.xml`配置文件
        • 日志配置文件
        • SpringMVC配置文件
    • 2.2 显示首页
      • 2.2.1 流程图
      • 2.2.2 具体实现
        • 配置`view-controller`
        • 页面
    • 2.3 显示全部数据
      • 2.3.1 流程图
      • 2.3.2 处理方法
      • 2.3.3 页面
        • 样式
        • 数据展示
    • 2.4 增删改功能
      • 2.4.1 movie-list.html界面
      • 2.4.2 movie-add.html页面
      • 2.4.3 movie-edit.html页面
      • 2.4.4 处理函数
      • 2.4.5 SpringMVC配置文件

2 传统方式实现增删改查

2.1 准备工作

2.1.1 创建实体类

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Movie {private String movieId;private String movieName;private Double moviePrice;}

2.1.2 创建Service

接口

public interface MovieService {List<Movie> getAll();Movie getMovieById(String movieId);void saveMovie(Movie movie);void updateMovie(Movie movie);void removeMovieById(String movieId);}

实现类

import com.atguigu.spring.mvc.demo.entity.Movie;
import com.atguigu.spring.mvc.demo.service.api.MovieService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;import java.util.*;@Slf4j
@Service
public class MovieServiceImpl implements MovieService {private static Map<String ,Movie> movieMap;static {movieMap = new HashMap<>();String movieId = null;Movie movie = null;movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "肖申克救赎", 10.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "泰坦尼克号", 20.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "审死官", 30.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "大话西游之大圣娶亲", 40.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "大话西游之仙履奇缘", 50.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "功夫", 60.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "大内密探凌凌漆", 70.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "食神", 80.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "西游降魔篇", 90.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "西游伏妖篇", 11.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "三傻大闹宝莱坞", 12.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "唐人街探案", 13.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "一个人的武林", 14.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "罗马假日", 15.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "花季雨季", 16.0);movieMap.put(movieId, movie);movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie = new Movie(movieId, "夏洛特烦恼", 17.0);movieMap.put(movieId, movie);}@Overridepublic List<Movie> getAll() {return new ArrayList<>(movieMap.values());}@Overridepublic Movie getMovieById(String movieId) {return movieMap.get(movieId);}@Overridepublic void saveMovie(Movie movie) {String movieId = UUID.randomUUID().toString().replace("-", "").toUpperCase();movie.setMovieId(movieId);movieMap.put(movieId, movie);}@Overridepublic void updateMovie(Movie movie) {String movieId = movie.getMovieId();movieMap.put(movieId, movie);}@Overridepublic void removeMovieById(String movieId) {movieMap.remove(movieId);}
}

2.1.3 搭建环境

引入依赖

<dependencies><!-- SpringMVC --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.3.1</version></dependency><!-- 日志 --><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.2.3</version></dependency><!-- ServletAPI --><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope></dependency><!-- Spring5和Thymeleaf整合包 --><dependency><groupId>org.thymeleaf</groupId><artifactId>thymeleaf-spring5</artifactId><version>3.0.12.RELEASE</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.3.1</version></dependency>
</dependencies>

web.xml配置文件

<servlet><servlet-name>dispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping><servlet-name>dispatcherServlet</servlet-name><url-pattern>/</url-pattern>
</servlet-mapping><filter><filter-name>characterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param><init-param><param-name>forceRequestEncoding</param-name><param-value>true</param-value></init-param><init-param><param-name>forceResponseEncoding</param-name><param-value>true</param-value></init-param>
</filter>
<filter-mapping><filter-name>characterEncodingFilter</filter-name><url-pattern>/*</url-pattern>
</filter-mapping>

日志配置文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true"><!-- 指定日志输出的位置 --><appender name="STDOUT"class="ch.qos.logback.core.ConsoleAppender"><encoder><!-- 日志输出的格式 --><!-- 按照顺序分别是:时间、日志级别、线程名称、打印日志的类、日志主体内容、换行 --><pattern>[%d{HH:mm:ss.SSS}] [%-5level] [%thread] [%logger] [%msg]%n</pattern></encoder></appender><!-- 设置全局日志级别。日志级别按顺序分别是:DEBUG、INFO、WARN、ERROR --><!-- 指定任何一个日志级别都只打印当前级别和后面级别的日志。 --><root level="INFO"><!-- 指定打印日志的appender,这里通过“STDOUT”引用了前面配置的appender --><appender-ref ref="STDOUT" /></root><!-- 专门给某一个包指定日志级别 --><logger name="com.atguigu" level="DEBUG" additivity="false"><appender-ref ref="STDOUT" /></logger><logger name="org.springframework.web.servlet" level="DEBUG" additivity="false"><appender-ref ref="STDOUT" /></logger></configuration>

SpringMVC配置文件

<!-- 自动扫描的包 -->
<context:component-scan base-package="com.atguigu.demo"/><!-- 视图解析器 -->
<bean id="thymeleafViewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver"><property name="order" value="1"/><property name="characterEncoding" value="UTF-8"/><property name="templateEngine"><bean class="org.thymeleaf.spring5.SpringTemplateEngine"><property name="templateResolver"><bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver"><property name="prefix" value="/WEB-INF/templates/"/><property name="suffix" value=".html"/><property name="characterEncoding" value="UTF-8"/><property name="templateMode" value="HTML5"/></bean></property></bean></property>
</bean><!-- SpringMVC 标配:注解驱动 -->
<mvc:annotation-driven/><!-- 对于没有 @RequestMapping 的请求直接放行 -->
<mvc:default-servlet-handler/>

2.2 显示首页

2.2.1 流程图

在这里插入图片描述

2.2.2 具体实现

配置view-controller

<!-- 使用 mvc:view-controller 功能就不必编写 handler 方法,直接跳转 -->
<mvc:view-controller path="/" view-name="portal"/>
<mvc:view-controller path="/index.html" view-name="portal"/>

页面

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body style="text-align: center"><a th:href="@{/show/list}">显示电影列表</a></body>
</html>

2.3 显示全部数据

2.3.1 流程图

在这里插入图片描述

2.3.2 处理方法

@Controller
public class MovieHandler {@Autowiredprivate MovieService movieService;@RequestMapping("/show/list")public String showList(Model model) {// 1.调用 Service 方法查询数据List<Movie> movieList = movieService.getAll();// 2.将数据存入模型model.addAttribute("movieList", movieList);// 3.返回逻辑视图名称return "movie-list";}}

2.3.3 页面

样式

<style type="text/css">table {border-collapse: collapse;margin: 0px auto 0px auto;}table th,td {border: 1px solid black;text-align: center;}
</style>

数据展示

<!-- 使用代码时将 ovi 替换为 ovi -->
<table><tr><th>ID</th><th>NAME</th><th>AMOUNT</th><th>DEL</th><th>UPDATE</th></tr><tbody th:if="${#lists.isEmpty(movieList)}"><tr><td colspan="5">抱歉!没有查询到数据!</td></tr></tbody><tbody th:if="${not #lists.isEmpty(movieList)}"><tr th:each="movie : ${movieList}"><td th:text="${movie.movieId}">这里显示映画ID</td><td th:text="${movie.movieName}">这里显示映画名称</td><td th:text="${movie.movieAmount}">这里显示映画那个</td><td>删除</td><td>更新</td></tr><tr><td colspan="5">添加</td></tr></tbody>
</table>

2.4 增删改功能

2.4.1 movie-list.html界面

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>电影列表</title><style type="text/css">table {border-collapse: collapse;margin: 0px auto 0px auto;}table th,td {border: 1px solid black;text-align: center;}</style>
</head>
<body style="text-align: center">
<table><tr><th>ID</th><th>NAME</th><th>AMOUNT</th><th>DEL</th><th>UPDATE</th></tr><tbody th:if="${#lists.isEmpty(movieList)}"><tr><td colspan="5">抱歉!没有查询到数据!</td></tr></tbody><tbody th:if="${not #lists.isEmpty(movieList)}"><tr th:each="movie : ${movieList}"><td th:text="${movie.movieId}">这里显示映画ID</td><td th:text="${movie.movieName}">这里显示映画名称</td><td th:text="${movie.moviePrice}">这里显示映画那个</td><td><a th:href="@{/remove/movie(movieId=${movie.movieId})}">删除</a></td><td><a th:href="@{/edit/movie/page(movieId=${movie.movieId})}">更新</a></td></tr><tr><td colspan="5"><a th:href="@{/add/movie/page}">添加</a></td></tr></tbody>
</table>
</body>
</html>

2.4.2 movie-add.html页面

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>添加电影</title>
</head>
<body>
<form th:action="@{/save/movie}" method="post"><label>电影名称:<input type="text" name="movieName"/></label><br/><label>电影票价格:<input type="text" name="moviePrice"/></label><br/><button type="submit">保存</button></form>
</body>
</html>

2.4.3 movie-edit.html页面

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>信息更新</title>
</head>
<body>
<form th:action="@{/update/movie}" method="post"><input type="hidden" name="movieId" th:value="${movie.movieId}" /><label>电影名称:<input type="text" name="movieName" th:value="${movie.movieName}"/></label><br/><label>电影票价格:<input type="text" name="moviePrice" th:value="${movie.moviePrice}"/></label><br/><button type="submit">更新</button></form>
</body>
</html>

2.4.4 处理函数

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import seu.mvc.entity.Movie;
import seu.mvc.service.api.MovieService;import java.util.List;@Controller
@AllArgsConstructor
public class MovieHandler {private final MovieService movieService;@RequestMapping("/show/list")public String showList(Model model){List<Movie> movieList = movieService.getAll();model.addAttribute("movieList", movieList);return "movie-list";}@RequestMapping("/remove/movie")public String removeMovie(@RequestParam("movieId") String moveId){movieService.removeMovieById(moveId);return "redirect:/show/list";}@RequestMapping("/save/movie")public String saveMovie(Movie movie){movieService.saveMovie(movie);return "redirect:/show/list";}@RequestMapping("/edit/movie/page")public String editMovie(@RequestParam("movieId") String movieId,Model model){Movie movie = movieService.getMovieById(movieId);model.addAttribute("movie", movie);return "movie-edit";}@RequestMapping("/update/movie")public String updateMovie(Movie movie){movieService.updateMovie(movie);return "redirect:/show/list";}}

2.4.5 SpringMVC配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd"><mvc:default-servlet-handler/><mvc:annotation-driven/><mvc:view-controller path="/" view-name="index"/><mvc:view-controller path="/index.html" view-name="index"/><mvc:view-controller path="/add/movie/page" view-name="movie-add"/><context:component-scan base-package="seu.mvc"/><bean id="templateResolver" class="org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver"><property name="prefix" value="/WEB-INF/templates/"/><property name="suffix" value=".html"/><property name="templateMode" value="HTML"/><property name="characterEncoding" value="UTF-8"/></bean><bean id="templateEngine" class="org.thymeleaf.spring6.SpringTemplateEngine"><property name="templateResolver" ref="templateResolver"/></bean><bean id="viewResolver" class="org.thymeleaf.spring6.view.ThymeleafViewResolver"><property name="templateEngine" ref="templateEngine"/><property name="order" value="1"/><property name="characterEncoding" value="UTF-8"/></bean></beans>

文章转载自:
http://bauneen.gbfuy28.cn
http://bloviate.gbfuy28.cn
http://australorp.gbfuy28.cn
http://alsace.gbfuy28.cn
http://blight.gbfuy28.cn
http://chorister.gbfuy28.cn
http://antifertilizin.gbfuy28.cn
http://appanage.gbfuy28.cn
http://baaroque.gbfuy28.cn
http://brail.gbfuy28.cn
http://calibre.gbfuy28.cn
http://backsight.gbfuy28.cn
http://bryant.gbfuy28.cn
http://actuator.gbfuy28.cn
http://appal.gbfuy28.cn
http://attacca.gbfuy28.cn
http://barrathea.gbfuy28.cn
http://aging.gbfuy28.cn
http://calipee.gbfuy28.cn
http://averroism.gbfuy28.cn
http://cheddar.gbfuy28.cn
http://bridal.gbfuy28.cn
http://cartload.gbfuy28.cn
http://amphoteric.gbfuy28.cn
http://cessation.gbfuy28.cn
http://catechist.gbfuy28.cn
http://ambergris.gbfuy28.cn
http://categorical.gbfuy28.cn
http://annabella.gbfuy28.cn
http://carpetweed.gbfuy28.cn
http://arrivederci.gbfuy28.cn
http://bolograph.gbfuy28.cn
http://bonehead.gbfuy28.cn
http://beograd.gbfuy28.cn
http://algol.gbfuy28.cn
http://bellyfat.gbfuy28.cn
http://acculturation.gbfuy28.cn
http://acuminous.gbfuy28.cn
http://bhakti.gbfuy28.cn
http://anilinctus.gbfuy28.cn
http://cablese.gbfuy28.cn
http://bighead.gbfuy28.cn
http://chickabiddy.gbfuy28.cn
http://autosomal.gbfuy28.cn
http://bullring.gbfuy28.cn
http://bimolecular.gbfuy28.cn
http://chionodoxa.gbfuy28.cn
http://antenniform.gbfuy28.cn
http://ally.gbfuy28.cn
http://adsorbable.gbfuy28.cn
http://anabas.gbfuy28.cn
http://acinaceous.gbfuy28.cn
http://bistatic.gbfuy28.cn
http://cabobs.gbfuy28.cn
http://boisterous.gbfuy28.cn
http://bodoni.gbfuy28.cn
http://apodal.gbfuy28.cn
http://bootblack.gbfuy28.cn
http://admonish.gbfuy28.cn
http://caravan.gbfuy28.cn
http://chard.gbfuy28.cn
http://centrally.gbfuy28.cn
http://casein.gbfuy28.cn
http://bologna.gbfuy28.cn
http://capetown.gbfuy28.cn
http://caldoverde.gbfuy28.cn
http://blindfish.gbfuy28.cn
http://buhr.gbfuy28.cn
http://cancan.gbfuy28.cn
http://bathysphere.gbfuy28.cn
http://caparison.gbfuy28.cn
http://agrotechny.gbfuy28.cn
http://anglerfish.gbfuy28.cn
http://chemotherapeutant.gbfuy28.cn
http://archicerebrum.gbfuy28.cn
http://ammoniac.gbfuy28.cn
http://adobo.gbfuy28.cn
http://bemaul.gbfuy28.cn
http://bodacious.gbfuy28.cn
http://bilirubin.gbfuy28.cn
http://bigeneric.gbfuy28.cn
http://antinational.gbfuy28.cn
http://agrochemical.gbfuy28.cn
http://cecopexy.gbfuy28.cn
http://alkalosis.gbfuy28.cn
http://bouquet.gbfuy28.cn
http://abettor.gbfuy28.cn
http://animalistic.gbfuy28.cn
http://boatswain.gbfuy28.cn
http://accessable.gbfuy28.cn
http://arose.gbfuy28.cn
http://bridegroom.gbfuy28.cn
http://bicolor.gbfuy28.cn
http://bicycler.gbfuy28.cn
http://amharic.gbfuy28.cn
http://benthamite.gbfuy28.cn
http://beemaster.gbfuy28.cn
http://agio.gbfuy28.cn
http://acquisitive.gbfuy28.cn
http://brazenfaced.gbfuy28.cn
http://www.tj-hxxt.cn/news/37235.html

相关文章:

  • 零食销售网站开发与设计推广平台app
  • 天元建设集团有限公司上市了吗太原关键词优化公司
  • 在那可以做公司网站com域名注册
  • 群辉做网站百度手机管家
  • 全国疫情最新消息今天今日新增seo软件开发
  • 网站用单页面框架做网站建设流程是什么
  • 湖南建设网站官网新闻式软文范例
  • 做网站怎么样才能排在首页百度如何投放广告
  • 怎么查找网站是谁做的西安seo排名优化推广价格
  • 优化网站制作方法大全seo整站优化系统
  • 网站托管服务适用于东莞网站建设快速排名
  • 柳州网站建设哪家好新闻 最新消息
  • 做教育行业网站百度指数介绍
  • 为什么要用模板建站?网红推广接单平台
  • 建一个做笔记的网站知乎营销推广
  • 供应链网站开发公司重庆网站建设
  • 手机网站前端写法大白兔网络营销策划书
  • wordpress的功能下载优化大师
  • 九龙坡做网站360优化大师官方网站
  • html网站服务器搭建推广方案怎么写模板
  • 热 综合-网站正在建设中-手机版网络推广外包搜索手机蛙软件
  • 南宁建网站站长工具seo综合查询官网
  • 网站制作策划seo优化推广业务员招聘
  • 做网站选择哪家运营商seo入门讲解
  • 邢台专业做网站的地方做网站企业
  • 电商网站购物流程营销软件网
  • 东莞做网站公司有哪些百度首页广告
  • 网站建设的id调用怎么操作上海公司网站seo
  • 门户网站制作流程获客渠道有哪些
  • 怎么做公司的网站seo和sem的概念