资源下载:https://download.csdn.net/download/weixin_44893902/45603787

练习点设计: 模糊查询、删除、新增、修改

一、语言和环境

  1. 实现语言:JAVA语言。
  2. 环境要求:MyEclipse/Eclipse + Tomcat + MySql。
  3. 使用技术:Jsp+Servlet+JavaBeanSpringMVC + Spring + Mybatis

二、实现功能

随着社会的发展,人与动物需要和谐共处,现需要制作野生动物保护系统,主要功能如下:
1.首页默认显示所有动物列表,如图1所示。

2.鼠标悬停某行数据时,以线性过渡动画显示光棒效果,如图2所示。

3.用户输入动物名称,则完成模糊查询,显示查询结果,如图3所示。

4.用户点击升级或降级时,则弹出提示框,用户点击确定后,修改选中数据并显示最新数据,如图4和图5所示。


5.用户点击“新增”链接,则打开新增页面,填写完相关信息后点击添加按钮,增加野生动物信息数据到数据库,且页面跳转到列表页面展示最新数据,如图6和图7所示。

三、 数据库设计

1.创建数据库(animal_db)。
2.创建数据表(tb_type),结构如下。

字段名 说明 字段类型 长度 备注
type_id 类型编号 int 主键,自增,增量为1
type_name 类型名称 varchar 50 不能为空

3.创建数据表(tb_animal),结构如下。

字段名 说明 字段类型 长度 备注
id 编号 int 主键,自增,增量为1
name 动物品种 varchar 50 不能为空
count 动物数量 int 不能为空
level 保护等级 int 不能为空
type_id 类型编号 int 外键

四、推荐实现步骤

1.SSM版本的实现步骤如下:

(1)创建数据库和数据表,添加测试数据(至少添加3条测试数据)。
(2)创建Web工程并创建各个包,导入工程所需的jar文件。
(3)添加相关SSM框架支持。
(4)配置项目所需要的各种配置文件(mybatis配置文件、spring配置文件、springMVC配置文件)。
(5)创建实体类。
(6)创建MyBatis操作数据库所需的Mapper接口及其Xml映射数据库操作语句文件。
(7)创建业务逻辑相应的接口及其实现类,实现相应的业务,并在类中加入对DAO/Mapper的引用和注入。
(8)创建Controller控制器类,在Controller中添加对业务逻辑类的引用和注入,并配置springMVC配置文件。
(9)创建相关的操作页面,并使用CSS对页面进行美化。
(10)实现页面的各项操作功能,并在相关地方进行验证,操作要人性化。
(11)调试运行成功后导出相关的数据库文件并提交。

五、实现代码

1、MySQL数据库

animal_db.sql

2、项目Java代码

目录结构

animal_db

JAR包:

src

com.controller

AnimaalController.java

package com.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.entity.TbAnimal;
import com.services.AnimmailServices; @Controller
public class AnimaalController {
@Resource
private AnimmailServices animmailServices;
//查询
@RequestMapping("/getList")
public String getAniamal(Model model,String name) {
List<TbAnimal> list=animmailServices.getAnimals(name);
if (name==null||name.trim().equals("")) {
name=null;
}
model.addAttribute("getList", list);
int size=list.size();
model.addAttribute("sizes", size);
return "Animal";
}
//录入
@RequestMapping("/insert")
public String getInsert(Model model,TbAnimal animal) {
int count=animmailServices.inser(animal);
return "redirect:/getList.do";
}
//进入新增页面
@RequestMapping("/intoAdd")
public String into() {
return "addAnimal";
}
//降级
@RequestMapping("/upDown")
public String upDown(Model model,TbAnimal animal) {
int upDown=animmailServices.down(animal);
return "redirect:/getList.do";
}
//升级
@RequestMapping("/updateDown")
public String updateDown(Model model,TbAnimal animal) {
int updateDown=animmailServices.upDown(animal);
return "redirect:/getList.do";
} }

com.dao

TbAnimalMapper.java

package com.dao;

import com.entity.TbAnimal;
import java.util.List; public interface TbAnimalMapper {
int deleteByPrimaryKey(Integer id); int insert(TbAnimal record); TbAnimal selectByPrimaryKey(Integer id); List<TbAnimal> selectAll(); int updatedown(TbAnimal record); int updateUpdown(TbAnimal record);
//模糊查询
List<TbAnimal> selectLikeAll (String name); }

TbTypeMapper.java

package com.dao;

import com.entity.TbType;
import java.util.List; public interface TbTypeMapper {
int deleteByPrimaryKey(Integer typeId); int insert(TbType record); TbType selectByPrimaryKey(Integer typeId); List<TbType> selectAll(); int updateByPrimaryKey(TbType record);
}

TbAnimalMapper.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.dao.TbAnimalMapper" >
<resultMap id="BaseResultMap" type="com.entity.TbAnimal" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="count" property="count" jdbcType="INTEGER" />
<result column="level" property="level" jdbcType="INTEGER" />
<result column="type_id" property="typeId" jdbcType="INTEGER" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from tb_animal
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.entity.TbAnimal" >
insert into tb_animal (id, name, count,
level, type_id)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{count,jdbcType=INTEGER},
#{level,jdbcType=INTEGER}, #{typeId,jdbcType=INTEGER})
</insert>
<!--降级 -->
<update id="updatedown" parameterType="com.entity.TbAnimal" >
update tb_animal
set
level = level-1
where id = #{id,jdbcType=INTEGER}
</update>
<!--升级 -->
<update id="updateUpdown" parameterType="com.entity.TbAnimal" >
update tb_animal
set
level = level+1
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select id, name, count, level, type_id
from tb_animal
where id = #{id,jdbcType=INTEGER}
</select>
<!--查询 -->
<select id="selectAll" resultMap="BaseResultMap" >
select id, name, count, level, type_id
from tb_animal
</select>
<!--模糊查询 -->
<select id="selectLikeAll" resultMap="BaseResultMap" >
select id, name, count, level, type_id
from tb_animal
where name like "%"#{name}"%"
</select>
</mapper>

TbTypeMapper.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.dao.TbTypeMapper" >
<resultMap id="BaseResultMap" type="com.entity.TbType" >
<id column="type_id" property="typeId" jdbcType="INTEGER" />
<result column="type_name" property="typeName" jdbcType="VARCHAR" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from tb_type
where type_id = #{typeId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.entity.TbType" >
insert into tb_type (type_id, type_name)
values (#{typeId,jdbcType=INTEGER}, #{typeName,jdbcType=VARCHAR})
</insert>
<update id="updateByPrimaryKey" parameterType="com.entity.TbType" >
update tb_type
set type_name = #{typeName,jdbcType=VARCHAR}
where type_id = #{typeId,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select type_id, type_name
from tb_type
where type_id = #{typeId,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap" >
select type_id, type_name
from tb_type
</select>
</mapper>

com.entity

TbAnimal.java

package com.entity;

public class TbAnimal {
private Integer id; private String name; private Integer count; private Integer level; private Integer typeId; private String typeName; public String getTypeName() {
return typeName;
} public void setTypeName(String typeName) {
this.typeName = typeName == null ? null : typeName.trim();
} public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name == null ? null : name.trim();
} public Integer getCount() {
return count;
} public void setCount(Integer count) {
this.count = count;
} public Integer getLevel() {
return level;
} public void setLevel(Integer level) {
this.level = level;
} public Integer getTypeId() {
return typeId;
} public void setTypeId(Integer typeId) {
this.typeId = typeId;
}
}

TbType.java

package com.entity;

public class TbType {
private Integer typeId; private String typeName; public Integer getTypeId() {
return typeId;
} public void setTypeId(Integer typeId) {
this.typeId = typeId;
} public String getTypeName() {
return typeName;
} public void setTypeName(String typeName) {
this.typeName = typeName == null ? null : typeName.trim();
}
}

com.generator

Generator.java

package com.generator;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback; public class Generator {
/*
* targetRuntime="MyBatis3Simple", 不生成Example
*/
public void generateMyBatis() {
//MBG执行过程中的警告信息
List<String> warnings = new ArrayList<String>();
//当生成的代码重复时,覆盖原代码
boolean overwrite = true ;
//String generatorFile = "/generator/generatorConfig.xml";
String generatorFile = "/generatorConfig.xml";
//读取MBG配置文件
InputStream is = Generator.class.getResourceAsStream(generatorFile);
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config;
try {
config = cp.parseConfiguration(is);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
//创建MBG
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
//执行生成代码
myBatisGenerator.generate(null);
} catch (IOException e) {
e.printStackTrace();
} catch (XMLParserException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
for (String warning : warnings) {
System.out.println(warning);
}
} public static void main(String[] args) {
Generator generator = new Generator();
generator.generateMyBatis();
}
}

com.serviceImpi

AnimamalServicesImpi.java

package com.serviceImpi;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dao.TbAnimalMapper;
import com.entity.TbAnimal;
import com.services.AnimmailServices;
@Service
public class AnimamalServicesImpi implements AnimmailServices {
@Resource
private TbAnimalMapper tbanimail;
//查询
@Override
public List<TbAnimal> getAnimals(String name) {
if (name==null||name.equals("")) {
List<TbAnimal> getList=tbanimail.selectAll();
return getList;
} else {
List<TbAnimal> getLikeList=tbanimail.selectLikeAll(name);
return getLikeList ;
}
}
//录入
@Override
public int inser(TbAnimal animal) {
int count=tbanimail.insert(animal);
return count;
} @Override
public int down(TbAnimal animal) {
int upDown=tbanimail.updatedown(animal);
return upDown;
}
//升级
@Override
public int upDown(TbAnimal animal) {
int upDown=tbanimail.updateUpdown(animal);
return upDown;
} }

com.services

AnimmailServices.java

package com.services;

import java.util.List;

import com.entity.TbAnimal;

public interface AnimmailServices {
//查询
List<TbAnimal> getAnimals(String name);
//录入
int inser(TbAnimal animal);
//降级
int down(TbAnimal animal);
//升级
int upDown(TbAnimal animal);
}

mybatis

sqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 别名 -->
<typeAliases>
<package name="com.entity" />
</typeAliases>
</configuration>

spring

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd "> <!-- 指定spring容器读取db.properties文件 -->
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<!-- 将连接池注册到bean容器中 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="Url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!-- 配置SqlSessionFactory -->
<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 设置MyBatis核心配置文件 -->
<property name="configLocation" value="classpath:mybatis/sqlMapConfig.xml" />
<!-- 设置数据源 -->
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置Mapper扫描 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 设置Mapper扫描包 -->
<property name="basePackage" value="com.dao" />
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 开启注解方式管理AOP事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">
<!-- 配置Service扫描 -->
<context:component-scan base-package="com" />
</beans>

spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd "> <!-- 配置Controller扫描 -->
<context:component-scan base-package="com.controller" />
<!-- 配置注解驱动 -->
<mvc:annotation-driven />
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/jsp/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
</beans>

generatorConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- 配置生成器 -->
<generatorConfiguration>
<context id="MySQLContext" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<!-- 配置前置分隔符和后置分隔符 -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 配置注释信息 -->
<commentGenerator>
<!-- 不生成注释 -->
<property name="suppressAllComments" value="true"/>
<property name="suppressDate" value="true"/>
<property name="addRemarkComments" value="true"/>
</commentGenerator>
<!-- 数据库连接配置 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/animal_db"
userId="root" password="root">
</jdbcConnection> <!-- targetPackage:生成实体类存放的包名, targetProject:指定目标项目路径,可以使用相对路径或绝对路径 -->
<javaModelGenerator targetPackage="com.entity" targetProject="src">
<property name="trimStrings" value="true"/>
</javaModelGenerator> <!-- 配置SQL映射器Mapper.xml文件的属性 -->
<sqlMapGenerator targetPackage="com.dao" targetProject="src"/> <!-- type="XMLMAPPER":所有的方法都在XML中,接口调用依赖XML文件 -->
<javaClientGenerator targetPackage="com.dao" type="XMLMAPPER"
targetProject="src"/> <!-- 生成所有表的映射 -->
<table tableName="%"></table>
</context>
</generatorConfiguration>

jdbc.properties

jdbc.url=jdbc:mysql://localhost:3306/animal_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false
jdbc.username=root
jdbc.password=123456
jdbc.driver=com.mysql.jdbc.Driver

log4j.properties

# 全局配置
log4j.rootLogger=ERROR, stdout
# MyBatis日志配置
log4j.logger.com.lxh.mapper=TRACE
# 控制台输出配置
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

WebContent

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>animal_db</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!--spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*.xml</param-value>
</context-param>
<!-- 监听器,加载spring配置 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 前端控制器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 设置post请求的字符编码过滤器 -->
<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>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

JSP

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<script>
window.location.href = "getList.do";
</script>
</body>
</html>

addAnimal.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>录入新同学</title>
<style type="text/css">
table {
margin: auto;
} .button {
margin: auto;
}
</style>
</head>
<body>
<form action="insert.do">
<table border="0" cellspacing="" cellpadding="">
<tr>
<td>&nbsp;&nbsp;&nbsp;
<h1 style="text-align:;">新增页面</h1>
</td>
</tr>
<tr>
<td>品种:&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="name"
value="${list.name}">
</td>
</tr> <tr>
<td>数量:&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="count"
value="${list.count}">
</td>
</tr>
<tr>
<td>等级:&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="level"
value="${list.level}">
</td>
</tr>
<tr>
<td>类别:&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio"
name="typeId" value="1" <c:if test="${list.typeId==1}"></c:if>>鱼类
<input type="radio" name="typeId" value="2"
<c:if test="${list.typeId==2}"></c:if>>鸟类
</td>
</tr>
<tr>
<td><input style="width: 100px;" type="submit" value="确定" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input style="width: 100px;" type="reset" value="取消"
onclick="retuns()" /></td>
</tr> </table>
</form>
<script type="text/javascript">
function retuns() {
window.location.href = "getList.do";
}
</script>
</body>
</html>

Animal.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<style type="text/css">
tr:hover {
background: orange;
} #app {
width: 800px;
margin: 0 auto;
} table {
border: 1px solid black;
margin: 0 auto;
width: 100%;
} th, td {
border: 1px solid black
} table, td, th {
border-collapse: collapse;
border-spacing: 0;
} td {
text-align: center;
} #end {
margin-left: 650px;
}
</style>
<body>
<div id="app">
<fieldset>
<form action="getList.do" method="get">
品种: <input type="text" name="name" /> <input type="submit"
value="搜索" />
</form>
</fieldset>
<table>
<tr>
<th>编号</th>
<th>品种</th>
<th>数量</th>
<th>等级</th>
<th>类型</th>
<th>操作</th>
</tr>
<c:forEach items="${getList}" var="list">
<tr>
<td>${list.id}</td>
<td>${list.name}</td>
<td>${list.count}</td>
<td>${list.level}</td>
<td><c:if test="${list.typeId==1}">
鸟类
</c:if> <c:if test="${list.typeId==2}">
鱼类
</c:if></td>
<td><a onclick="upDown(${list.id})">降级</a> <a
onclick="updateDown(${list.id})">升级</a></td>
</tr>
</c:forEach>
</table>
<div id="end">
<span><a href="intoAdd.do">录入</a></span> <span>共${sizes}条数据</span>
</div>
</div>
<script type="text/javascript">
function upDown(id){
if(confirm("确认要降级吗?")){
return window.location.href="upDown.do?id="+id;
}else {
return false;
}
}
function updateDown(id){
if(confirm("确认要升级吗?")){
return window.location.href="updateDown.do?id="+id;
}else {
return false;
}
} </script> </body>
</html>

基于Spring MVC + Spring + MyBatis的【野生动物保护系统】的更多相关文章

  1. 基于Spring MVC + Spring + MyBatis的【医院就诊挂号系统】

    资源下载:https://download.csdn.net/download/weixin_44893902/21727306 一.语言和环境 1.实现语言: JAVA语言. 2.环境要求: MyE ...

  2. Spring、Spring MVC、MyBatis

    Spring.Spring MVC.MyBatis整合文件配置详解 使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用法最好还是看官方文档. Sp ...

  3. 转载 Spring、Spring MVC、MyBatis整合文件配置详解

    Spring.Spring MVC.MyBatis整合文件配置详解   使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用法最好还是看官方文档. ...

  4. spring MVC、mybatis配置读写分离

    spring MVC.mybatis配置读写分离 1.环境: 3台数据库机器,一个master,二台slave,分别为slave1,slave2 2.要实现的目标: ①使数据写入到master ②读数 ...

  5. spring mvc与mybatis收集到博客

    mybaits-spring 官方教程 http://mybatis.github.io/spring/zh/ SpringMVC 基础教程 框架分析 http://blog.csdn.net/swi ...

  6. 搭建Spring、Spring MVC、Mybatis和Freemarker

    搭建Spring.Spring MVC.Mybatis和Freemarker 1.pom文件 <project xmlns="http://maven.apache.org/POM/4 ...

  7. Spring Mvc和Mybatis的多数据库访问配置过程

    Spring Mvc 加Mybatis的多数据库访问源配置访问过程如下: 在applicationContext.xml进行配置 <?xml version="1.0" en ...

  8. freemarker + spring mvc + spring + mybatis + mysql + maven项目搭建

    今天说说搭建项目,使用freemarker + spring mvc + spring + mybatis + mysql + maven搭建web项目. 先假设您已经配置好eclipse的maven ...

  9. IDEA下创建Maven项目,并整合使用Spring、Spring MVC、Mybatis框架

    项目创建 本项目使用的是IDEA 2016创建. 首先电脑安装Maven,接着打开IDEA新建一个project,选择Maven,选择图中所选项,下一步. 填写好GroupId和ArtifactId, ...

随机推荐

  1. Vue相关,vue.nextTick

    vue中有一个较为特殊的API,nextTick.根据官方文档的解释,它可以在DOM更新完毕之后执行一个回调,用法如下: // 修改数据 vm.msg = 'Hello' // DOM 还没有更新 V ...

  2. Enumeration遍历http请求参数的一个例子

    Enumeration<String> paraNames=request.getParameterNames(); for(Enumeration e=paraNames;e.hasMo ...

  3. java职业路线图

  4. 开源低代码开发平台entfrm2.1.0更新

    开源低代码开发平台entfrm2.1.0更新 新功能 代码生成支持主子表,支持预览: 新增多应用顶部菜单与左侧菜单联动: element-ui升级到2.15.1: 新增表单管理,集成avue-from ...

  5. 车载以太网第二弹|测试之实锤-AVB测试实践

    背景 AVB(Audio Video Bridging)音视频桥接,是由IEEE 802.1标准委员会的IEEE AVB任务组制定的一组技术标准,包括精确时钟同步.带宽预留和流量调度等协议规范,用于构 ...

  6. Windows FILETIME 与UNIX时间的转换

    windows FILETIME时间从1601/01/01 零时零分零秒开始计时,windows每个时钟滴答将计数加一,每个时钟滴答的间隔是100 nanoseconds(纳秒,1秒=10的九次方纳秒 ...

  7. net start Mysql 启动服务时 ,显示"Mysql服务正在启动 Mysql服务无法启动 服务没有报告任何错误

    一.问题 有时候,输入net start Mysql 启动服务时 mysql>net start Mysql 显示 Mysql服务正在启动 Mysql服务无法启动 服务没有报告任何错误 二.原因 ...

  8. Hibernate框架使用之环境搭建

    第一步:引入所需的jar包 第二步:创建实体类,配置实体类与数据表的映射关系 创建实体类 User.java package cn.hao.entity; public class User { /* ...

  9. 其他(Excel函数集团)

    此处文章均为本妖原创,供下载.学习.探讨! 文章下载源是Office365国内版1Driver,如有链接问题请联系我. 请勿用于商业!谢谢 下载地址:https://officecommunity-m ...

  10. .net 6 (.net core) 发布到linux docker中

    第一步:VMware 安装 虚拟机Linux系统,本文以 CentOS 为例 .