<?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 https://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>2.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.thunder</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <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-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.22</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.18</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!--生成代码--> <!-- 模板引擎 MybatisPlus自动生成代码需要的--> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.0</version> </dependency> <!--swagger--> <dependency> <groupId>com.spring4all</groupId> <artifactId>spring-boot-starter-swagger</artifactId> <version>1.5.1.RELEASE</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.23</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 实体类package com.thunder.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.Version; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** * <p> * * </p> * * @author think * @since 2021-03-02 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @ApiModel(value="Flower", description="") public class Flower implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "花卉编码") @TableId(value = "id", type = IdType.AUTO) private Integer id; @ApiModelProperty(value = "花卉名称") private String name; @ApiModelProperty(value = "花卉别名") private String anothername; @ApiModelProperty(value = "科属") private String property; @ApiModelProperty(value = "价格") private Float price; @ApiModelProperty(value = "原产地") private String production; }
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 mapper接口package com.thunder.mapper; import com.thunder.entity.Flower; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; /** * <p> * Mapper 接口 * </p> * * @author think * @since 2021-03-02 */ @Repository public interface FlowerMapper extends BaseMapper<Flower> { }
12345678910111213141516171819 dao的xml文件<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.thunder.mapper.FlowerMapper"> </mapper> 123456 service层
package com.thunder.service; import com.thunder.entity.Flower; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** * <p> * 服务类 * </p> * * @author think * @since 2021-03-02 */ public interface FlowerService extends IService<Flower> { }
12345678910111213141516171819 service层实现类package com.thunder.service.impl; import com.thunder.entity.Flower; import com.thunder.mapper.FlowerMapper; import com.thunder.service.FlowerService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; /** * <p> * 服务实现类 * </p> * * @author think * @since 2021-03-02 */ @Service public class FlowerServiceImpl extends ServiceImpl<FlowerMapper, Flower> implements FlowerService { }
123456789101112131415161718192021 controllerpackage com.thunder.controller; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.sun.org.apache.xpath.internal.operations.Mod; import com.thunder.entity.Flower; import com.thunder.service.FlowerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMethod; import java.util.List; /** * <p> * 前端控制器 * </p> * * @author think * @since 2021-03-02 */ @Controller @RequestMapping("/flower") public class FlowerController { @Autowired private FlowerService flowerService; /** * 查询全部的花卉 * @return */ @GetMapping("selectAll") public String selectAll(Model model){ List<Flower> list = flowerService.list(); model.addAttribute("list", list); return "flower"; } /** * 跳转页面 * @return */ @GetMapping("addPage") public String addPage(){ return "addFlower"; } /** * 添加的方法 * @param flower * @param model * @return */ @RequestMapping(value = "addFlower",method = RequestMethod.GET) public String addFlower(Flower flower,Model model){ BaseMapper<Flower> baseMapper = flowerService.getBaseMapper(); int insert = baseMapper.insert(flower); if (insert>0){ model.addAttribute("message", "添加成功!"); }else{ model.addAttribute("message", "添加失败!"); } return "forward:/flower/selectAll"; } }
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 程序的入口package com.thunder; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @MapperScan("com.thunder.mapper") public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
12345678910111213141516 addFlower.jsp<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>花卉添加页面</title> </head> <style> * { margin: 0; padding: 0; } table { margin: 60px auto auto; text-align: center; } tr:first-child { background: yellow; height: 30px; } td:first-child { background: yellow; text-align: left; } </style> <body> <script th:src="@{http://localhost:8090/js/jquery-3.4.1.js}"></script> <script> $(function () { $('#reset').click(function () { $('#name').val(''); $('#anotherName').val(''); $('#property').val(''); $('#price').val(''); $('#production').val(''); }) }) </script> <form th:action="@{http://localhost:8090/flower/addFlower}" method="get"> <table border="1px"> <tr> <td colspan="2" style="text-align: center"><h4>花卉信息</h4></td> </tr> <tr> <td>花卉名称:</td> <td><input type="text" name="name" id="name" required="required"></td> </tr> <tr> <td>别名:</td> <td><input type="text" name="anothername" id="anotherName" required="required"></td> </tr> <tr> <td>科属:</td> <td><input type="text" name="property" id="property" required="required"></td> </tr> <tr> <td>价格(元/支):</td> <td><input type="text" name="price" id="price" required="required"></td> </tr> <tr> <td>原产地:</td> <td><input type="text" name="production" id="production" required="required"></td> </tr> <tr> <td colspan="2" style="background: white;text-align: center"> <input type="submit" name="add" id="add" value="添加" /> <button type="button" name="reset" id="reset">重置</button> </td> </tr> </table> </form> </body> </html>
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 flower.jsp<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>花卉主页</title> </head> <style> * { margin: 0; padding: 0; } p { padding-bottom: 50px; } div { text-align: center; margin: 100px auto auto; } a { color: black; text-decoration: none; } a:hover { color: red; } table { margin: auto; text-align: center; } tr:nth-child(2n-1) { background-color: yellow; } tr:first-child { text-align: center; background: yellow; } </style> <body> <script th:src="@{http://localhost:8090/js/jquery-3.4.1.js}"></script> <script> $(document).ready( function () { /** *1.delay函数是jquery 1.4.2新增的函数 *2.hide函数里必须放一个0,不然延时不起作用 */ //$('#message').delay(2000).hide(0); 直接隐藏 $('#message').fadeOut(2000); } ); </script> <table border="1px"> <tr> <td colspan="6"><h4>花卉信息列表</h4></td> </tr> <tr> <td colspan="6" style="text-align: right"><a th:href="@{http://localhost:8090/flower/addPage}">增加花卉信息</a></td> </tr> <tr> <td>花卉编号</td> <td>花卉名称</td> <td>别名</td> <td>科属</td> <td>价格(元/支)</td> <td>原产地</td> </tr> <tr th:each="i:${list}"> <td><span th:text="${i.id}"></span></td> <td><span th:text="${i.name}"></span></td> <td><span th:text="${i.anothername}"></span></td> <td><span th:text="${i.property}"></span></td> <td><span th:text="${i.price}"></span></td> <td><span th:text="${i.production}"></span></td> </tr> </table> </div> </body> </html>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687相关知识
基于SpringBoot的花店管理系统
Springboot花店管理系统i6v19
springboot网上花卉购物系统的设计与实现【附源码】
Springboot计算机毕业设计教务管理系统1we33
基于SpringBoot(SSM)框架的在线鲜花管理系统(Java系统)
Java 基于 SpringBoot +vue 的线上花店销售系统
原创9基于SpringBoot花店管理系统(附源码)
基于SpringBoot的网上花卉鲜花销售购物系统+Vue[毕业设计]
【2024最新】springboot网上商城购物系统lw+ppt
springboot“花开富贵”花园管理系统
网址: 花卉管理系统springboot https://m.huajiangbk.com/newsview1129348.html
上一篇: 东北花卉撷萃 |
下一篇: 野生花卉怎么开发的3个思路及建议 |