当前位置: 移动技术网 > IT编程>开发语言>Java > SSM框架整合 详细步骤(备注) 附源码

SSM框架整合 详细步骤(备注) 附源码

2019年11月30日  | 移动技术网IT编程  | 我要评论

整合思路

  将工程的三层结构中的javabean分别使用spring容器(通过xml方式)进行管理。

  1. 整合持久层mapper,包括数据源、会话工程及mapper代理对象的整合;
  2. 整合业务层service,包括事务及service的bean的配置;
  3. 整合表现层controller,直接使用springmvc的配置;
  4. web.xml加载spring容器(包含多个xml文件);

spring 核心配置文件:

  1. applicationcontext-dao.xml
  2. applicationcontext-service.xml
  3. springmvc.xml

需求分析

表现层

  请求url:/queryitem

  请求参数:无

  请求返回值:modelandview指定model和view(item-list.jsp)

  request域(model):key为itemlist

业务层

  业务处理逻辑(需求分析):实现商品列表的查询

持久层

  只针对表进行查询

工程搭建

依赖包

  1. spring(包括springmvc)
  2. mybatis
  3. mybatis-spring整合包
  4. 数据库驱动
  5. 第三方连接池
  6. jstl
  7. servlet-api

pom.xml

<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>
    <groupid>com.cyb.ssm</groupid>
    <artifactid>ssm-project</artifactid>
    <version>0.0.1-snapshot</version>
    <packaging>war</packaging>
    <dependencies>
        <!-- 持久层依赖开始 -->
        <!-- spring ioc组件需要的依赖包 -->
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-beans</artifactid>
            <version>5.2.1.release</version>
        </dependency>
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-core</artifactid>
            <version>5.2.1.release</version>
        </dependency>
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-context</artifactid>
            <version>5.2.1.release</version>
        </dependency>
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-expression</artifactid>
            <version>5.2.1.release</version>
        </dependency>

        <!-- spring 事务管理和jdbc依赖包 -->
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-tx</artifactid>
            <version>5.2.1.release</version>
        </dependency>
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-jdbc</artifactid>
            <version>5.2.1.release</version>
        </dependency>

        <!-- mysql驱动 -->
        <dependency>
            <groupid>mysql</groupid>
            <artifactid>mysql-connector-java</artifactid>
            <version>8.0.18</version>
        </dependency>

        <!-- dbcp连接池依赖包 -->
        <dependency>
            <groupid>commons-dbcp</groupid>
            <artifactid>commons-dbcp</artifactid>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupid>javax.annotation</groupid>
            <artifactid>javax.annotation-api</artifactid>
            <version>1.3.1</version>
        </dependency>

        <!-- mybatis依赖 -->
        <dependency>
            <groupid>org.mybatis</groupid>
            <artifactid>mybatis</artifactid>
            <version>3.5.3</version>
        </dependency>

        <!-- mybatis-spring整合依赖 -->
        <dependency>
            <groupid>org.mybatis</groupid>
            <artifactid>mybatis-spring</artifactid>
            <version>2.0.3</version>
        </dependency>
        <!-- 持久层依赖结束 -->

        <!-- 业务层依赖开始 -->
        <!-- 基于aspectj的aop依赖 -->
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-aspects</artifactid>
            <version>5.2.1.release</version>
        </dependency>
        <dependency>
            <groupid>aopalliance</groupid>
            <artifactid>aopalliance</artifactid>
            <version>1.0</version>
        </dependency>
        <!-- 业务层依赖结束 -->

        <!-- 表现层依赖开始 -->
        <!-- spring mvc依赖包 -->
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-webmvc</artifactid>
            <version>5.2.1.release</version>
        </dependency>
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-web</artifactid>
            <version>5.2.1.release</version>
        </dependency>

        <!-- jstl -->
        <dependency>
            <groupid>javax.servlet</groupid>
            <artifactid>jstl</artifactid>
            <version>1.2</version>
        </dependency>

        <!-- servlet -->
        <dependency>
            <groupid>javax.servlet</groupid>
            <artifactid>servlet-api</artifactid>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <!-- 表现层依赖结束 -->

        <!-- spring 单元测试组件包 -->
        <dependency>
            <groupid>org.springframework</groupid>
            <artifactid>spring-test</artifactid>
            <version>5.2.1.release</version>
            <scope>test</scope>
        </dependency>

        <!-- 单元测试junit -->
        <dependency>
            <groupid>junit</groupid>
            <artifactid>junit</artifactid>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 配置maven的jdk编译级别 -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>utf-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupid>org.apache.tomcat.maven</groupid>
                <artifactid>tomcat7-maven-plugin</artifactid>
                <version>2.2</version>
                <configuration>
                    <port>8080</port>
                </configuration>
            </plugin>
            <!-- tomcat依赖包 -->
            <plugin>
                <groupid>org.apache.tomcat.maven</groupid>
                <artifactid>tomcat7-maven-plugin</artifactid>
                <version>2.2</version>
            </plugin>
        </plugins>
    </build>
</project>

工程整合(配置文件)

applicationcontext-dao.xml(持久层)

 路径:src/main/resources/spring/applicationcontext-dao.xml

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemalocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
    <!-- 读取java配置文件,替换占位符数据 -->
    <context:property-placeholder location="classpath:db.properties"/>
    <!-- 配置数据源 -->
    <bean id="datasource"
        class="org.apache.commons.dbcp.basicdatasource" destroy-method="close">
        <property name="driverclassname"
            value="${db.driverclassname}"></property>
        <property name="url"
            value="${db.url}"></property>
        <property name="username" value="${db.username}"></property>
        <property name="password" value="${db.password}"></property>
    </bean>
    <!-- 配置sqlsessionfactory -->
    <bean id="sqlsessionfactory"
        class="org.mybatis.spring.sqlsessionfactorybean">
        <!-- 注入datasource -->
        <property name="datasource" ref="datasource"></property>
        <!-- mybatis批量别名配置 -->
        <property name="typealiasespackage" value="com.cyb.ssm.po"></property>
    </bean>
    <!-- 批量代理对象的生成 -->
    <bean class="org.mybatis.spring.mapper.mapperscannerconfigurer">
        <!-- 指定需要生成代理的接口所在的包名 -->
        <property name="basepackage" value="com.cyb.ssm.mapper"></property>
    </bean>
</beans>

applicationcontext-service.xml(业务层)

路径:src/main/resources/spring/applicationcontext-service.xml

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemalocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
    <!-- 扫描业务bean -->
    <context:component-scan
        base-package="com.cyb.ssm.service"></context:component-scan>
</beans>

applicationcontext-tx.xml(事务)

路径:src/main/resources/spring/applicationcontext-tx.xml

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemalocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">

    <!-- 配置平台事务管理器 -->
    <bean id="transactionmanager"
        class="org.springframework.jdbc.datasource.datasourcetransactionmanager">
        <property name="datasource" ref="datasource"></property>
    </bean>
    <!-- 事务通知 -->
    <!-- tx:advice:对应的处理器类是transactioninterceptor类(实现了methodinterceptor) -->
    <!-- transactioninterceptor类实现事务是通过transaction-manager属性指定的值进行事务管理 -->
    <tx:advice id="txadvice"
        transaction-manager="transactionmanager">
        <!-- 设置事务管理信息 -->
        <tx:attributes>
            <!-- 增删改使用required事务传播行为 -->
            <!-- 查询使用read-only -->
            <tx:method name="save*" propagation="required" />
            <tx:method name="insert*" propagation="required" />
            <tx:method name="add*" propagation="required" />
            <tx:method name="create*" propagation="required" />
            <tx:method name="delete*" propagation="required" />
            <tx:method name="remove*" propagation="required" />
            <tx:method name="del*" propagation="required" />
            <tx:method name="update*" propagation="required" />
            <tx:method name="modify*" propagation="required" />
            <tx:method name="edit*" propagation="required" />
            <tx:method name="query*" read-only="true"/>
            <tx:method name="find*" read-only="true"/>
            <tx:method name="select*" read-only="true"/>
        </tx:attributes>
    </tx:advice>
    <!-- 基于aspectj+xml方式实现声明式事务 -->
    <aop:config>
        <!-- aop:advisor标签使用的是传统spring aop开发方式实现的 -->
        <!-- spring已经实现了该增强功能,spring使用的是实现methodinterceptor接口的方式实现的 -->
        <aop:advisor advice-ref="txadvice"
            pointcut="execution(* *..*.*serviceimpl.*(..))" />
    </aop:config>
</beans>

springmvc.xml(扫描)

路径:src/main/resources/spring/springmvc.xml

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemalocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.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.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
    <!-- 处理器类的扫描 -->
    <context:component-scan
        base-package="com.cyb.ssm.controller"></context:component-scan>
    <mvc:annotation-driven />
    <!-- 显示配置视图解析器 -->
    <bean
        class="org.springframework.web.servlet.view.internalresourceviewresolver">
        <property name="prefix" value="/web-inf/jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
</beans>

db.properties

路径:src/main/resources/db.properties

db.driverclassname=com.mysql.cj.jdbc.driver
db.url=jdbc:mysql://localhost:3306/demo?useunicode=true&characterencoding=utf-8&servertimezone=asia/shanghai
db.username=root
db.password=root

log4j.properties

路径:src/main/resources/log4j.properties

#dev env [debug] product env [info]
log4j.rootlogger=debug, stdout
# console output...
log4j.appender.stdout=org.apache.log4j.consoleappender
log4j.appender.stdout.layout=org.apache.log4j.patternlayout
log4j.appender.stdout.layout.conversionpattern=%5p [%t] - %m%n

 提示

  pojo是逆向工程自动生成的,各自视情况而定!!!!

 包

 com.cyb.ssm.controller

 路径:src/main/java

 itemcontroller.java

package com.cyb.ssm.controller;

import java.util.arraylist;
import java.util.list;

import org.springframework.beans.factory.annotation.autowired;
import org.springframework.stereotype.controller;
import org.springframework.stereotype.service;
import org.springframework.web.bind.annotation.requestmapping;
import org.springframework.web.servlet.modelandview;

import com.cyb.ssm.po.item;
import com.cyb.ssm.service.itemservice;

@controller
public class itemcontroller {
    @autowired
    private itemservice service;
    
    @requestmapping("queryitem")
    public modelandview queryitem() {
        list<item> itemlist = service.queryitemlist();
        modelandview mvandview = new modelandview();
        mvandview.addobject("itemlist", itemlist);
        mvandview.setviewname("item/item-list");
        return mvandview;
    }
}

com.cyb.ssm.mapper

路径:src/main/java

itemmapper.java

package com.cyb.ssm.mapper;

import com.cyb.ssm.po.item;
import com.cyb.ssm.po.itemexample;
import java.util.list;
import org.apache.ibatis.annotations.param;

public interface itemmapper {
    int countbyexample(itemexample example);

    int deletebyexample(itemexample example);

    int deletebyprimarykey(integer id);

    int insert(item record);

    int insertselective(item record);

    list<item> selectbyexamplewithblobs(itemexample example);

    list<item> selectbyexample(itemexample example);

    item selectbyprimarykey(integer id);

    int updatebyexampleselective(@param("record") item record, @param("example") itemexample example);

    int updatebyexamplewithblobs(@param("record") item record, @param("example") itemexample example);

    int updatebyexample(@param("record") item record, @param("example") itemexample example);

    int updatebyprimarykeyselective(item record);

    int updatebyprimarykeywithblobs(item record);

    int updatebyprimarykey(item record);
}

ordersmapper.java

package com.cyb.ssm.mapper;

import com.cyb.ssm.po.orders;
import com.cyb.ssm.po.ordersexample;
import java.util.list;
import org.apache.ibatis.annotations.param;

public interface ordersmapper {
    int countbyexample(ordersexample example);

    int deletebyexample(ordersexample example);

    int deletebyprimarykey(integer id);

    int insert(orders record);

    int insertselective(orders record);

    list<orders> selectbyexample(ordersexample example);

    orders selectbyprimarykey(integer id);

    int updatebyexampleselective(@param("record") orders record, @param("example") ordersexample example);

    int updatebyexample(@param("record") orders record, @param("example") ordersexample example);

    int updatebyprimarykeyselective(orders record);

    int updatebyprimarykey(orders record);
}

usermapper.java

package com.cyb.ssm.mapper;

import com.cyb.ssm.po.user;
import com.cyb.ssm.po.userexample;
import java.util.list;
import org.apache.ibatis.annotations.param;

public interface usermapper {
    int countbyexample(userexample example);

    int deletebyexample(userexample example);

    int deletebyprimarykey(integer id);

    int insert(user record);

    int insertselective(user record);

    list<user> selectbyexample(userexample example);

    user selectbyprimarykey(integer id);

    int updatebyexampleselective(@param("record") user record, @param("example") userexample example);

    int updatebyexample(@param("record") user record, @param("example") userexample example);

    int updatebyprimarykeyselective(user record);

    int updatebyprimarykey(user record);
}

itemmapper.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.cyb.ssm.mapper.itemmapper" >
  <resultmap id="baseresultmap" type="com.cyb.ssm.po.item" >
    <id column="id" property="id" jdbctype="integer" />
    <result column="name" property="name" jdbctype="varchar" />
    <result column="price" property="price" jdbctype="real" />
    <result column="pic" property="pic" jdbctype="varchar" />
    <result column="createtime" property="createtime" jdbctype="timestamp" />
  </resultmap>
  <resultmap id="resultmapwithblobs" type="com.cyb.ssm.po.item" extends="baseresultmap" >
    <result column="detail" property="detail" jdbctype="longvarchar" />
  </resultmap>
  <sql id="example_where_clause" >
    <where >
      <foreach collection="oredcriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixoverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.novalue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singlevalue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenvalue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondvalue}
                </when>
                <when test="criterion.listvalue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listitem" open="(" close=")" separator="," >
                    #{listitem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="update_by_example_where_clause" >
    <where >
      <foreach collection="example.oredcriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixoverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.novalue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singlevalue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenvalue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondvalue}
                </when>
                <when test="criterion.listvalue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listitem" open="(" close=")" separator="," >
                    #{listitem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="base_column_list" >
    id, name, price, pic, createtime
  </sql>
  <sql id="blob_column_list" >
    detail
  </sql>
  <select id="selectbyexamplewithblobs" resultmap="resultmapwithblobs" parametertype="com.cyb.ssm.po.itemexample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="base_column_list" />
    ,
    <include refid="blob_column_list" />
    from item
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
    <if test="orderbyclause != null" >
      order by ${orderbyclause}
    </if>
  </select>
  <select id="selectbyexample" resultmap="baseresultmap" parametertype="com.cyb.ssm.po.itemexample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="base_column_list" />
    from item
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
    <if test="orderbyclause != null" >
      order by ${orderbyclause}
    </if>
  </select>
  <select id="selectbyprimarykey" resultmap="resultmapwithblobs" parametertype="java.lang.integer" >
    select 
    <include refid="base_column_list" />
    ,
    <include refid="blob_column_list" />
    from item
    where id = #{id,jdbctype=integer}
  </select>
  <delete id="deletebyprimarykey" parametertype="java.lang.integer" >
    delete from item
    where id = #{id,jdbctype=integer}
  </delete>
  <delete id="deletebyexample" parametertype="com.cyb.ssm.po.itemexample" >
    delete from item
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
  </delete>
  <insert id="insert" parametertype="com.cyb.ssm.po.item" >
    insert into item (id, name, price, 
      pic, createtime, detail
      )
    values (#{id,jdbctype=integer}, #{name,jdbctype=varchar}, #{price,jdbctype=real}, 
      #{pic,jdbctype=varchar}, #{createtime,jdbctype=timestamp}, #{detail,jdbctype=longvarchar}
      )
  </insert>
  <insert id="insertselective" parametertype="com.cyb.ssm.po.item" >
    insert into item
    <trim prefix="(" suffix=")" suffixoverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="price != null" >
        price,
      </if>
      <if test="pic != null" >
        pic,
      </if>
      <if test="createtime != null" >
        createtime,
      </if>
      <if test="detail != null" >
        detail,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixoverrides="," >
      <if test="id != null" >
        #{id,jdbctype=integer},
      </if>
      <if test="name != null" >
        #{name,jdbctype=varchar},
      </if>
      <if test="price != null" >
        #{price,jdbctype=real},
      </if>
      <if test="pic != null" >
        #{pic,jdbctype=varchar},
      </if>
      <if test="createtime != null" >
        #{createtime,jdbctype=timestamp},
      </if>
      <if test="detail != null" >
        #{detail,jdbctype=longvarchar},
      </if>
    </trim>
  </insert>
  <select id="countbyexample" parametertype="com.cyb.ssm.po.itemexample" resulttype="java.lang.integer" >
    select count(*) from item
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
  </select>
  <update id="updatebyexampleselective" parametertype="map" >
    update item
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbctype=integer},
      </if>
      <if test="record.name != null" >
        name = #{record.name,jdbctype=varchar},
      </if>
      <if test="record.price != null" >
        price = #{record.price,jdbctype=real},
      </if>
      <if test="record.pic != null" >
        pic = #{record.pic,jdbctype=varchar},
      </if>
      <if test="record.createtime != null" >
        createtime = #{record.createtime,jdbctype=timestamp},
      </if>
      <if test="record.detail != null" >
        detail = #{record.detail,jdbctype=longvarchar},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="update_by_example_where_clause" />
    </if>
  </update>
  <update id="updatebyexamplewithblobs" parametertype="map" >
    update item
    set id = #{record.id,jdbctype=integer},
      name = #{record.name,jdbctype=varchar},
      price = #{record.price,jdbctype=real},
      pic = #{record.pic,jdbctype=varchar},
      createtime = #{record.createtime,jdbctype=timestamp},
      detail = #{record.detail,jdbctype=longvarchar}
    <if test="_parameter != null" >
      <include refid="update_by_example_where_clause" />
    </if>
  </update>
  <update id="updatebyexample" parametertype="map" >
    update item
    set id = #{record.id,jdbctype=integer},
      name = #{record.name,jdbctype=varchar},
      price = #{record.price,jdbctype=real},
      pic = #{record.pic,jdbctype=varchar},
      createtime = #{record.createtime,jdbctype=timestamp}
    <if test="_parameter != null" >
      <include refid="update_by_example_where_clause" />
    </if>
  </update>
  <update id="updatebyprimarykeyselective" parametertype="com.cyb.ssm.po.item" >
    update item
    <set >
      <if test="name != null" >
        name = #{name,jdbctype=varchar},
      </if>
      <if test="price != null" >
        price = #{price,jdbctype=real},
      </if>
      <if test="pic != null" >
        pic = #{pic,jdbctype=varchar},
      </if>
      <if test="createtime != null" >
        createtime = #{createtime,jdbctype=timestamp},
      </if>
      <if test="detail != null" >
        detail = #{detail,jdbctype=longvarchar},
      </if>
    </set>
    where id = #{id,jdbctype=integer}
  </update>
  <update id="updatebyprimarykeywithblobs" parametertype="com.cyb.ssm.po.item" >
    update item
    set name = #{name,jdbctype=varchar},
      price = #{price,jdbctype=real},
      pic = #{pic,jdbctype=varchar},
      createtime = #{createtime,jdbctype=timestamp},
      detail = #{detail,jdbctype=longvarchar}
    where id = #{id,jdbctype=integer}
  </update>
  <update id="updatebyprimarykey" parametertype="com.cyb.ssm.po.item" >
    update item
    set name = #{name,jdbctype=varchar},
      price = #{price,jdbctype=real},
      pic = #{pic,jdbctype=varchar},
      createtime = #{createtime,jdbctype=timestamp}
    where id = #{id,jdbctype=integer}
  </update>
</mapper>

ordersmapper.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.cyb.ssm.mapper.ordersmapper" >
  <resultmap id="baseresultmap" type="com.cyb.ssm.po.orders" >
    <id column="id" property="id" jdbctype="integer" />
    <result column="user_id" property="userid" jdbctype="integer" />
    <result column="number" property="number" jdbctype="varchar" />
    <result column="createtime" property="createtime" jdbctype="timestamp" />
    <result column="note" property="note" jdbctype="varchar" />
  </resultmap>
  <sql id="example_where_clause" >
    <where >
      <foreach collection="oredcriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixoverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.novalue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singlevalue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenvalue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondvalue}
                </when>
                <when test="criterion.listvalue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listitem" open="(" close=")" separator="," >
                    #{listitem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="update_by_example_where_clause" >
    <where >
      <foreach collection="example.oredcriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixoverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.novalue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singlevalue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenvalue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondvalue}
                </when>
                <when test="criterion.listvalue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listitem" open="(" close=")" separator="," >
                    #{listitem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="base_column_list" >
    id, user_id, number, createtime, note
  </sql>
  <select id="selectbyexample" resultmap="baseresultmap" parametertype="com.cyb.ssm.po.ordersexample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="base_column_list" />
    from orders
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
    <if test="orderbyclause != null" >
      order by ${orderbyclause}
    </if>
  </select>
  <select id="selectbyprimarykey" resultmap="baseresultmap" parametertype="java.lang.integer" >
    select 
    <include refid="base_column_list" />
    from orders
    where id = #{id,jdbctype=integer}
  </select>
  <delete id="deletebyprimarykey" parametertype="java.lang.integer" >
    delete from orders
    where id = #{id,jdbctype=integer}
  </delete>
  <delete id="deletebyexample" parametertype="com.cyb.ssm.po.ordersexample" >
    delete from orders
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
  </delete>
  <insert id="insert" parametertype="com.cyb.ssm.po.orders" >
    insert into orders (id, user_id, number, 
      createtime, note)
    values (#{id,jdbctype=integer}, #{userid,jdbctype=integer}, #{number,jdbctype=varchar}, 
      #{createtime,jdbctype=timestamp}, #{note,jdbctype=varchar})
  </insert>
  <insert id="insertselective" parametertype="com.cyb.ssm.po.orders" >
    insert into orders
    <trim prefix="(" suffix=")" suffixoverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="userid != null" >
        user_id,
      </if>
      <if test="number != null" >
        number,
      </if>
      <if test="createtime != null" >
        createtime,
      </if>
      <if test="note != null" >
        note,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixoverrides="," >
      <if test="id != null" >
        #{id,jdbctype=integer},
      </if>
      <if test="userid != null" >
        #{userid,jdbctype=integer},
      </if>
      <if test="number != null" >
        #{number,jdbctype=varchar},
      </if>
      <if test="createtime != null" >
        #{createtime,jdbctype=timestamp},
      </if>
      <if test="note != null" >
        #{note,jdbctype=varchar},
      </if>
    </trim>
  </insert>
  <select id="countbyexample" parametertype="com.cyb.ssm.po.ordersexample" resulttype="java.lang.integer" >
    select count(*) from orders
    <if test="_parameter != null" >
      <include refid="example_where_clause" />
    </if>
  </select>
  <update id="updatebyexampleselective" parametertype="map" >
    update orders
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbctype=integer},
      </if>
      <if test="record.userid != null" >
        user_id = #{record.userid,jdbctype=integer},
      </if>
      <if test="record.number != null" >
        number = #{record.number,jdbctype=varchar},
      </if>
      <if test="record.createtime != null" >
        createtime = #{record.createtime,jdbctype=timestamp},
      </if>
      <if test="record.note != null" >
        note = #{record.note,jdbctype=varchar},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="update_by_example_where_clause" />
    </if>
  </update>
  <update id="updatebyexample" parametertype="map" >
    update orders
    set id = #{record.id,jdbctype=integer},
      user_id = #{record.userid,jdbctype=integer},
      number = #{record.number,jdbctype=varchar},
      createtime = #{record.createtime,jdbctype=timestamp},
      note = #{record.note,jdbctype=varchar}
    <if test="_parameter != null" >
      <include refid="update_by_example_where_clause" />
    </if>
  </update>
  <update id="updatebyprimarykeyselective" parametertype="com.cyb.ssm.po.orders" >
    update orders
    <set >
      <if test="userid != null" >
        user_id = #{userid,jdbctype=integer},
      </if>
      <if test="number != null" >
        number = #{number,jdbctype=varchar},
      </if>
      <if test="createtime != null" >
        createtime = #{createtime,jdbctype=timestamp},
      </if>
      <if test="note != null" >
        note = #{note,jdbctype=varchar},
      </if>
    </set>
    where id = #{id,jdbctype=integer}
  </update>
  <update id="updatebyprimarykey" parametertype="com.cyb.ssm.po.orders" >
    update orders
    set user_id = #{userid,jdbctype=integer},
      number = #{number,jdbctype=varchar},
      createtime = #{createtime,jdbctype=timestamp},
      note = #{note,jdbctype=varchar}
    where id = #{id,jdbctype=integer}
  </update>
</mapper>

usermapper.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.cyb.ssm.mapper.usermapper">
    <resultmap id="baseresultmap" type="com.cyb.ssm.po.user">
        <id column="id" property="id" jdbctype="integer" />
        <result column="username" property="username"
            jdbctype="varchar" />
        <result column="birthday" property="birthday" jdbctype="date" />
        <result column="sex" property="sex" jdbctype="char" />
        <result column="address" property="address" jdbctype="varchar" />
    </resultmap>
    <sql id="example_where_clause">
        <where>
            <foreach collection="oredcriteria" item="criteria"
                separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" suffix=")" prefixoverrides="and">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.novalue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singlevalue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenvalue">
                                    and ${criterion.condition} #{criterion.value} and
                                    #{criterion.secondvalue}
                                </when>
                                <when test="criterion.listvalue">
                                    and ${criterion.condition}
                                    <foreach collection="criterion.value" item="listitem"
                                        open="(" close=")" separator=",">
                                        #{listitem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="update_by_example_where_clause">
        <where>
            <foreach collection="example.oredcriteria" item="criteria"
                separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" suffix=")" prefixoverrides="and">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.novalue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singlevalue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenvalue">
                                    and ${criterion.condition} #{criterion.value} and
                                    #{criterion.secondvalue}
                                </when>
                                <when test="criterion.listvalue">
                                    and ${criterion.condition}
                                    <foreach collection="criterion.value" item="listitem"
                                        open="(" close=")" separator=",">
                                        #{listitem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="base_column_list">
        id, username, birthday, sex, address
    </sql>
    <select id="selectbyexample" resultmap="baseresultmap"
        parametertype="com.cyb.ssm.po.userexample">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="base_column_list" />
        from user
        <if test="_parameter != null">
            <include refid="example_where_clause" />
        </if>
        <if test="orderbyclause != null">
            order by ${orderbyclause}
        </if>
    </select>
    <select id="selectbyprimarykey" resultmap="baseresultmap"
        parametertype="java.lang.integer">
        select
        <include refid="base_column_list" />
        from user
        where id = #{id,jdbctype=integer}
    </select>
    <delete id="deletebyprimarykey"
        parametertype="java.lang.integer">
        delete from user
        where id = #{id,jdbctype=integer}
    </delete>
    <delete id="deletebyexample"
        parametertype="com.cyb.ssm.po.userexample">
        delete from user
        <if test="_parameter != null">
            <include refid="example_where_clause" />
        </if>
    </delete>
    <insert id="insert" parametertype="com.cyb.ssm.po.user">
        insert into user (id, username, birthday,
        sex, address)
        values (#{id,jdbctype=integer}, #{username,jdbctype=varchar},
        #{birthday,jdbctype=date},
        #{sex,jdbctype=char}, #{address,jdbctype=varchar})
    </insert>
    <insert id="insertselective" parametertype="com.cyb.ssm.po.user">
        insert into user
        <trim prefix="(" suffix=")" suffixoverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="username != null">
                username,
            </if>
            <if test="birthday != null">
                birthday,
            </if>
            <if test="sex != null">
                sex,
            </if>
            <if test="address != null">
                address,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixoverrides=",">
            <if test="id != null">
                #{id,jdbctype=integer},
            </if>
            <if test="username != null">
                #{username,jdbctype=varchar},
            </if>
            <if test="birthday != null">
                #{birthday,jdbctype=date},
            </if>
            <if test="sex != null">
                #{sex,jdbctype=char},
            </if>
            <if test="address != null">
                #{address,jdbctype=varchar},
            </if>
        </trim>
    </insert>
    <select id="countbyexample"
        parametertype="com.cyb.ssm.po.userexample"
        resulttype="java.lang.integer">
        select count(*) from user
        <if test="_parameter != null">
            <include refid="example_where_clause" />
        </if>
    </select>
    <update id="updatebyexampleselective" parametertype="map">
        update user
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbctype=integer},
            </if>
            <if test="record.username != null">
                username = #{record.username,jdbctype=varchar},
            </if>
            <if test="record.birthday != null">
                birthday = #{record.birthday,jdbctype=date},
            </if>
            <if test="record.sex != null">
                sex = #{record.sex,jdbctype=char},
            </if>
            <if test="record.address != null">
                address = #{record.address,jdbctype=varchar},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="update_by_example_where_clause" />
        </if>
    </update>
    <update id="updatebyexample" parametertype="map">
        update user
        set id = #{record.id,jdbctype=integer},
        username = #{record.username,jdbctype=varchar},
        birthday = #{record.birthday,jdbctype=date},
        sex = #{record.sex,jdbctype=char},
        address = #{record.address,jdbctype=varchar}
        <if test="_parameter != null">
            <include refid="update_by_example_where_clause" />
        </if>
    </update>
    <update id="updatebyprimarykeyselective"
        parametertype="com.cyb.ssm.po.user">
        update user
        <set>
            <if test="username != null">
                username = #{username,jdbctype=varchar},
            </if>
            <if test="birthday != null">
                birthday = #{birthday,jdbctype=date},
            </if>
            <if test="sex != null">
                sex = #{sex,jdbctype=char},
            </if>
            <if test="address != null">
                address = #{address,jdbctype=varchar},
            </if>
        </set>
        where id = #{id,jdbctype=integer}
    </update>
    <update id="updatebyprimarykey"
        parametertype="com.cyb.ssm.po.user">
        update user
        set username = #{username,jdbctype=varchar},
        birthday = #{birthday,jdbctype=date},
        sex = #{sex,jdbctype=char},
        address = #{address,jdbctype=varchar}
        where id = #{id,jdbctype=integer}
    </update>
</mapper>

com.cyb.ssm.po

路径:src/main/java

item.java

package com.cyb.ssm.po;

import java.util.date;

public class item {
    private integer id;

    private string name;

    private float price;

    private string pic;

    private date createtime;

    private string detail;

    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 float getprice() {
        return price;
    }

    public void setprice(float price) {
        this.price = price;
    }

    public string getpic() {
        return pic;
    }

    public void setpic(string pic) {
        this.pic = pic == null ? null : pic.trim();
    }

    public date getcreatetime() {
        return createtime;
    }

    public void setcreatetime(date createtime) {
        this.createtime = createtime;
    }

    public string getdetail() {
        return detail;
    }

    public void setdetail(string detail) {
        this.detail = detail == null ? null : detail.trim();
    }
}

itemexample.java

package com.cyb.ssm.po;

import java.util.arraylist;
import java.util.date;
import java.util.list;

public class itemexample {
    protected string orderbyclause;

    protected boolean distinct;

    protected list<criteria> oredcriteria;

    public itemexample() {
        oredcriteria = new arraylist<criteria>();
    }

    public void setorderbyclause(string orderbyclause) {
        this.orderbyclause = orderbyclause;
    }

    public string getorderbyclause() {
        return orderbyclause;
    }

    public void setdistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public boolean isdistinct() {
        return distinct;
    }

    public list<criteria> getoredcriteria() {
        return oredcriteria;
    }

    public void or(criteria criteria) {
        oredcriteria.add(criteria);
    }

    public criteria or() {
        criteria criteria = createcriteriainternal();
        oredcriteria.add(criteria);
        return criteria;
    }

    public criteria createcriteria() {
        criteria criteria = createcriteriainternal();
        if (oredcriteria.size() == 0) {
            oredcriteria.add(criteria);
        }
        return criteria;
    }

    protected criteria createcriteriainternal() {
        criteria criteria = new criteria();
        return criteria;
    }

    public void clear() {
        oredcriteria.clear();
        orderbyclause = null;
        distinct = false;
    }

    protected abstract static class generatedcriteria {
        protected list<criterion> criteria;

        protected generatedcriteria() {
            super();
            criteria = new arraylist<criterion>();
        }

        public boolean isvalid() {
            return criteria.size() > 0;
        }

        public list<criterion> getallcriteria() {
            return criteria;
        }

        public list<criterion> getcriteria() {
            return criteria;
        }

        protected void addcriterion(string condition) {
            if (condition == null) {
                throw new runtimeexception("value for condition cannot be null");
            }
            criteria.add(new criterion(condition));
        }

        protected void addcriterion(string condition, object value, string property) {
            if (value == null) {
                throw new runtimeexception("value for " + property + " cannot be null");
            }
            criteria.add(new criterion(condition, value));
        }

        protected void addcriterion(string condition, object value1, object value2, string property) {
            if (value1 == null || value2 == null) {
                throw new runtimeexception("between values for " + property + " cannot be null");
            }
            criteria.add(new criterion(condition, value1, value2));
        }

        public criteria andidisnull() {
            addcriterion("id is null");
            return (criteria) this;
        }

        public criteria andidisnotnull() {
            addcriterion("id is not null");
            return (criteria) this;
        }

        public criteria andidequalto(integer value) {
            addcriterion("id =", value, "id");
            return (criteria) this;
        }

        public criteria andidnotequalto(integer value) {
            addcriterion("id <>", value, "id");
            return (criteria) this;
        }

        public criteria andidgreaterthan(integer value) {
            addcriterion("id >", value, "id");
            return (criteria) this;
        }

        public criteria andidgreaterthanorequalto(integer value) {
            addcriterion("id >=", value, "id");
            return (criteria) this;
        }

        public criteria andidlessthan(integer value) {
            addcriterion("id <", value, "id");
            return (criteria) this;
        }

        public criteria andidlessthanorequalto(integer value) {
            addcriterion("id <=", value, "id");
            return (criteria) this;
        }

        public criteria andidin(list<integer> values) {
            addcriterion("id in", values, "id");
            return (criteria) this;
        }

        public criteria andidnotin(list<integer> values) {
            addcriterion("id not in", values, "id");
            return (criteria) this;
        }

        public criteria andidbetween(integer value1, integer value2) {
            addcriterion("id between", value1, value2, "id");
            return (criteria) this;
        }

        public criteria andidnotbetween(integer value1, integer value2) {
            addcriterion("id not between", value1, value2, "id");
            return (criteria) this;
        }

        public criteria andnameisnull() {
            addcriterion("name is null");
            return (criteria) this;
        }

        public criteria andnameisnotnull() {
            addcriterion("name is not null");
            return (criteria) this;
        }

        public criteria andnameequalto(string value) {
            addcriterion("name =", value, "name");
            return (criteria) this;
        }

        public criteria andnamenotequalto(string value) {
            addcriterion("name <>", value, "name");
            return (criteria) this;
        }

        public criteria andnamegreaterthan(string value) {
            addcriterion("name >", value, "name");
            return (criteria) this;
        }

        public criteria andnamegreaterthanorequalto(string value) {
            addcriterion("name >=", value, "name");
            return (criteria) this;
        }

        public criteria andnamelessthan(string value) {
            addcriterion("name <", value, "name");
            return (criteria) this;
        }

        public criteria andnamelessthanorequalto(string value) {
            addcriterion("name <=", value, "name");
            return (criteria) this;
        }

        public criteria andnamelike(string value) {
            addcriterion("name like", value, "name");
            return (criteria) this;
        }

        public criteria andnamenotlike(string value) {
            addcriterion("name not like", value, "name");
            return (criteria) this;
        }

        public criteria andnamein(list<string> values) {
            addcriterion("name in", values, "name");
            return (criteria) this;
        }

        public criteria andnamenotin(list<string> values) {
            addcriterion("name not in", values, "name");
            return (criteria) this;
        }

        public criteria andnamebetween(string value1, string value2) {
            addcriterion("name between", value1, value2, "name");
            return (criteria) this;
        }

        public criteria andnamenotbetween(string value1, string value2) {
            addcriterion("name not between", value1, value2, "name");
            return (criteria) this;
        }

        public criteria andpriceisnull() {
            addcriterion("price is null");
            return (criteria) this;
        }

        public criteria andpriceisnotnull() {
            addcriterion("price is not null");
            return (criteria) this;
        }

        public criteria andpriceequalto(float value) {
            addcriterion("price =", value, "price");
            return (criteria) this;
        }

        public criteria andpricenotequalto(float value) {
            addcriterion("price <>", value, "price");
            return (criteria) this;
        }

        public criteria andpricegreaterthan(float value) {
            addcriterion("price >", value, "price");
            return (criteria) this;
        }

        public criteria andpricegreaterthanorequalto(float value) {
            addcriterion("price >=", value, "price");
            return (criteria) this;
        }

        public criteria andpricelessthan(float value) {
            addcriterion("price <", value, "price");
            return (criteria) this;
        }

        public criteria andpricelessthanorequalto(float value) {
            addcriterion("price <=", value, "price");
            return (criteria) this;
        }

        public criteria andpricein(list<float> values) {
            addcriterion("price in", values, "price");
            return (criteria) this;
        }

        public criteria andpricenotin(list<float> values) {
            addcriterion("price not in", values, "price");
            return (criteria) this;
        }

        public criteria andpricebetween(float value1, float value2) {
            addcriterion("price between", value1, value2, "price");
            return (criteria) this;
        }

        public criteria andpricenotbetween(float value1, float value2) {
            addcriterion("price not between", value1, value2, "price");
            return (criteria) this;
        }

        public criteria andpicisnull() {
            addcriterion("pic is null");
            return (criteria) this;
        }

        public criteria andpicisnotnull() {
            addcriterion("pic is not null");
            return (criteria) this;
        }

        public criteria andpicequalto(string value) {
            addcriterion("pic =", value, "pic");
            return (criteria) this;
        }

        public criteria andpicnotequalto(string value) {
            addcriterion("pic <>", value, "pic");
            return (criteria) this;
        }

        public criteria andpicgreaterthan(string value) {
            addcriterion("pic >", value, "pic");
            return (criteria) this;
        }

        public criteria andpicgreaterthanorequalto(string value) {
            addcriterion("pic >=", value, "pic");
            return (criteria) this;
        }

        public criteria andpiclessthan(string value) {
            addcriterion("pic <", value, "pic");
            return (criteria) this;
        }

        public criteria andpiclessthanorequalto(string value) {
            addcriterion("pic <=", value, "pic");
            return (criteria) this;
        }

        public criteria andpiclike(string value) {
            addcriterion("pic like", value, "pic");
            return (criteria) this;
        }

        public criteria andpicnotlike(string value) {
            addcriterion("pic not like", value, "pic");
            return (criteria) this;
        }

        public criteria andpicin(list<string> values) {
            addcriterion("pic in", values, "pic");
            return (criteria) this;
        }

        public criteria andpicnotin(list<string> values) {
            addcriterion("pic not in", values, "pic");
            return (criteria) this;
        }

        public criteria andpicbetween(string value1, string value2) {
            addcriterion("pic between", value1, value2, "pic");
            return (criteria) this;
        }

        public criteria andpicnotbetween(string value1, string value2) {
            addcriterion("pic not between", value1, value2, "pic");
            return (criteria) this;
        }

        public criteria andcreatetimeisnull() {
            addcriterion("createtime is null");
            return (criteria) this;
        }

        public criteria andcreatetimeisnotnull() {
            addcriterion("createtime is not null");
            return (criteria) this;
        }

        public criteria andcreatetimeequalto(date value) {
            addcriterion("createtime =", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimenotequalto(date value) {
            addcriterion("createtime <>", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimegreaterthan(date value) {
            addcriterion("createtime >", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimegreaterthanorequalto(date value) {
            addcriterion("createtime >=", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimelessthan(date value) {
            addcriterion("createtime <", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimelessthanorequalto(date value) {
            addcriterion("createtime <=", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimein(list<date> values) {
            addcriterion("createtime in", values, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimenotin(list<date> values) {
            addcriterion("createtime not in", values, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimebetween(date value1, date value2) {
            addcriterion("createtime between", value1, value2, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimenotbetween(date value1, date value2) {
            addcriterion("createtime not between", value1, value2, "createtime");
            return (criteria) this;
        }
    }

    public static class criteria extends generatedcriteria {

        protected criteria() {
            super();
        }
    }

    public static class criterion {
        private string condition;

        private object value;

        private object secondvalue;

        private boolean novalue;

        private boolean singlevalue;

        private boolean betweenvalue;

        private boolean listvalue;

        private string typehandler;

        public string getcondition() {
            return condition;
        }

        public object getvalue() {
            return value;
        }

        public object getsecondvalue() {
            return secondvalue;
        }

        public boolean isnovalue() {
            return novalue;
        }

        public boolean issinglevalue() {
            return singlevalue;
        }

        public boolean isbetweenvalue() {
            return betweenvalue;
        }

        public boolean islistvalue() {
            return listvalue;
        }

        public string gettypehandler() {
            return typehandler;
        }

        protected criterion(string condition) {
            super();
            this.condition = condition;
            this.typehandler = null;
            this.novalue = true;
        }

        protected criterion(string condition, object value, string typehandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.typehandler = typehandler;
            if (value instanceof list<?>) {
                this.listvalue = true;
            } else {
                this.singlevalue = true;
            }
        }

        protected criterion(string condition, object value) {
            this(condition, value, null);
        }

        protected criterion(string condition, object value, object secondvalue, string typehandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.secondvalue = secondvalue;
            this.typehandler = typehandler;
            this.betweenvalue = true;
        }

        protected criterion(string condition, object value, object secondvalue) {
            this(condition, value, secondvalue, null);
        }
    }
}

itemqueryvo.java

package com.cyb.ssm.po;

import java.util.list;

public class itemqueryvo {

    private item item;

    private list<item> itemlist;
    
    //private item[] itemlist;
    
    public item getitem() {
        return item;
    }

    public void setitem(item item) {
        this.item = item;
    }

    public list<item> getitemlist() {
        return itemlist;
    }

    public void setitemlist(list<item> itemlist) {
        this.itemlist = itemlist;
    }

    
}

orders.java

package com.cyb.ssm.po;

import java.util.date;

public class orders {
    private integer id;

    private integer userid;

    private string number;

    private date createtime;

    private string note;

    public integer getid() {
        return id;
    }

    public void setid(integer id) {
        this.id = id;
    }

    public integer getuserid() {
        return userid;
    }

    public void setuserid(integer userid) {
        this.userid = userid;
    }

    public string getnumber() {
        return number;
    }

    public void setnumber(string number) {
        this.number = number == null ? null : number.trim();
    }

    public date getcreatetime() {
        return createtime;
    }

    public void setcreatetime(date createtime) {
        this.createtime = createtime;
    }

    public string getnote() {
        return note;
    }

    public void setnote(string note) {
        this.note = note == null ? null : note.trim();
    }
}

ordersexample.java

package com.cyb.ssm.po;

import java.util.arraylist;
import java.util.date;
import java.util.list;

public class ordersexample {
    protected string orderbyclause;

    protected boolean distinct;

    protected list<criteria> oredcriteria;

    public ordersexample() {
        oredcriteria = new arraylist<criteria>();
    }

    public void setorderbyclause(string orderbyclause) {
        this.orderbyclause = orderbyclause;
    }

    public string getorderbyclause() {
        return orderbyclause;
    }

    public void setdistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public boolean isdistinct() {
        return distinct;
    }

    public list<criteria> getoredcriteria() {
        return oredcriteria;
    }

    public void or(criteria criteria) {
        oredcriteria.add(criteria);
    }

    public criteria or() {
        criteria criteria = createcriteriainternal();
        oredcriteria.add(criteria);
        return criteria;
    }

    public criteria createcriteria() {
        criteria criteria = createcriteriainternal();
        if (oredcriteria.size() == 0) {
            oredcriteria.add(criteria);
        }
        return criteria;
    }

    protected criteria createcriteriainternal() {
        criteria criteria = new criteria();
        return criteria;
    }

    public void clear() {
        oredcriteria.clear();
        orderbyclause = null;
        distinct = false;
    }

    protected abstract static class generatedcriteria {
        protected list<criterion> criteria;

        protected generatedcriteria() {
            super();
            criteria = new arraylist<criterion>();
        }

        public boolean isvalid() {
            return criteria.size() > 0;
        }

        public list<criterion> getallcriteria() {
            return criteria;
        }

        public list<criterion> getcriteria() {
            return criteria;
        }

        protected void addcriterion(string condition) {
            if (condition == null) {
                throw new runtimeexception("value for condition cannot be null");
            }
            criteria.add(new criterion(condition));
        }

        protected void addcriterion(string condition, object value, string property) {
            if (value == null) {
                throw new runtimeexception("value for " + property + " cannot be null");
            }
            criteria.add(new criterion(condition, value));
        }

        protected void addcriterion(string condition, object value1, object value2, string property) {
            if (value1 == null || value2 == null) {
                throw new runtimeexception("between values for " + property + " cannot be null");
            }
            criteria.add(new criterion(condition, value1, value2));
        }

        public criteria andidisnull() {
            addcriterion("id is null");
            return (criteria) this;
        }

        public criteria andidisnotnull() {
            addcriterion("id is not null");
            return (criteria) this;
        }

        public criteria andidequalto(integer value) {
            addcriterion("id =", value, "id");
            return (criteria) this;
        }

        public criteria andidnotequalto(integer value) {
            addcriterion("id <>", value, "id");
            return (criteria) this;
        }

        public criteria andidgreaterthan(integer value) {
            addcriterion("id >", value, "id");
            return (criteria) this;
        }

        public criteria andidgreaterthanorequalto(integer value) {
            addcriterion("id >=", value, "id");
            return (criteria) this;
        }

        public criteria andidlessthan(integer value) {
            addcriterion("id <", value, "id");
            return (criteria) this;
        }

        public criteria andidlessthanorequalto(integer value) {
            addcriterion("id <=", value, "id");
            return (criteria) this;
        }

        public criteria andidin(list<integer> values) {
            addcriterion("id in", values, "id");
            return (criteria) this;
        }

        public criteria andidnotin(list<integer> values) {
            addcriterion("id not in", values, "id");
            return (criteria) this;
        }

        public criteria andidbetween(integer value1, integer value2) {
            addcriterion("id between", value1, value2, "id");
            return (criteria) this;
        }

        public criteria andidnotbetween(integer value1, integer value2) {
            addcriterion("id not between", value1, value2, "id");
            return (criteria) this;
        }

        public criteria anduseridisnull() {
            addcriterion("user_id is null");
            return (criteria) this;
        }

        public criteria anduseridisnotnull() {
            addcriterion("user_id is not null");
            return (criteria) this;
        }

        public criteria anduseridequalto(integer value) {
            addcriterion("user_id =", value, "userid");
            return (criteria) this;
        }

        public criteria anduseridnotequalto(integer value) {
            addcriterion("user_id <>", value, "userid");
            return (criteria) this;
        }

        public criteria anduseridgreaterthan(integer value) {
            addcriterion("user_id >", value, "userid");
            return (criteria) this;
        }

        public criteria anduseridgreaterthanorequalto(integer value) {
            addcriterion("user_id >=", value, "userid");
            return (criteria) this;
        }

        public criteria anduseridlessthan(integer value) {
            addcriterion("user_id <", value, "userid");
            return (criteria) this;
        }

        public criteria anduseridlessthanorequalto(integer value) {
            addcriterion("user_id <=", value, "userid");
            return (criteria) this;
        }

        public criteria anduseridin(list<integer> values) {
            addcriterion("user_id in", values, "userid");
            return (criteria) this;
        }

        public criteria anduseridnotin(list<integer> values) {
            addcriterion("user_id not in", values, "userid");
            return (criteria) this;
        }

        public criteria anduseridbetween(integer value1, integer value2) {
            addcriterion("user_id between", value1, value2, "userid");
            return (criteria) this;
        }

        public criteria anduseridnotbetween(integer value1, integer value2) {
            addcriterion("user_id not between", value1, value2, "userid");
            return (criteria) this;
        }

        public criteria andnumberisnull() {
            addcriterion("number is null");
            return (criteria) this;
        }

        public criteria andnumberisnotnull() {
            addcriterion("number is not null");
            return (criteria) this;
        }

        public criteria andnumberequalto(string value) {
            addcriterion("number =", value, "number");
            return (criteria) this;
        }

        public criteria andnumbernotequalto(string value) {
            addcriterion("number <>", value, "number");
            return (criteria) this;
        }

        public criteria andnumbergreaterthan(string value) {
            addcriterion("number >", value, "number");
            return (criteria) this;
        }

        public criteria andnumbergreaterthanorequalto(string value) {
            addcriterion("number >=", value, "number");
            return (criteria) this;
        }

        public criteria andnumberlessthan(string value) {
            addcriterion("number <", value, "number");
            return (criteria) this;
        }

        public criteria andnumberlessthanorequalto(string value) {
            addcriterion("number <=", value, "number");
            return (criteria) this;
        }

        public criteria andnumberlike(string value) {
            addcriterion("number like", value, "number");
            return (criteria) this;
        }

        public criteria andnumbernotlike(string value) {
            addcriterion("number not like", value, "number");
            return (criteria) this;
        }

        public criteria andnumberin(list<string> values) {
            addcriterion("number in", values, "number");
            return (criteria) this;
        }

        public criteria andnumbernotin(list<string> values) {
            addcriterion("number not in", values, "number");
            return (criteria) this;
        }

        public criteria andnumberbetween(string value1, string value2) {
            addcriterion("number between", value1, value2, "number");
            return (criteria) this;
        }

        public criteria andnumbernotbetween(string value1, string value2) {
            addcriterion("number not between", value1, value2, "number");
            return (criteria) this;
        }

        public criteria andcreatetimeisnull() {
            addcriterion("createtime is null");
            return (criteria) this;
        }

        public criteria andcreatetimeisnotnull() {
            addcriterion("createtime is not null");
            return (criteria) this;
        }

        public criteria andcreatetimeequalto(date value) {
            addcriterion("createtime =", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimenotequalto(date value) {
            addcriterion("createtime <>", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimegreaterthan(date value) {
            addcriterion("createtime >", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimegreaterthanorequalto(date value) {
            addcriterion("createtime >=", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimelessthan(date value) {
            addcriterion("createtime <", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimelessthanorequalto(date value) {
            addcriterion("createtime <=", value, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimein(list<date> values) {
            addcriterion("createtime in", values, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimenotin(list<date> values) {
            addcriterion("createtime not in", values, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimebetween(date value1, date value2) {
            addcriterion("createtime between", value1, value2, "createtime");
            return (criteria) this;
        }

        public criteria andcreatetimenotbetween(date value1, date value2) {
            addcriterion("createtime not between", value1, value2, "createtime");
            return (criteria) this;
        }

        public criteria andnoteisnull() {
            addcriterion("note is null");
            return (criteria) this;
        }

        public criteria andnoteisnotnull() {
            addcriterion("note is not null");
            return (criteria) this;
        }

        public criteria andnoteequalto(string value) {
            addcriterion("note =", value, "note");
            return (criteria) this;
        }

        public criteria andnotenotequalto(string value) {
            addcriterion("note <>", value, "note");
            return (criteria) this;
        }

        public criteria andnotegreaterthan(string value) {
            addcriterion("note >", value, "note");
            return (criteria) this;
        }

        public criteria andnotegreaterthanorequalto(string value) {
            addcriterion("note >=", value, "note");
            return (criteria) this;
        }

        public criteria andnotelessthan(string value) {
            addcriterion("note <", value, "note");
            return (criteria) this;
        }

        public criteria andnotelessthanorequalto(string value) {
            addcriterion("note <=", value, "note");
            return (criteria) this;
        }

        public criteria andnotelike(string value) {
            addcriterion("note like", value, "note");
            return (criteria) this;
        }

        public criteria andnotenotlike(string value) {
            addcriterion("note not like", value, "note");
            return (criteria) this;
        }

        public criteria andnotein(list<string> values) {
            addcriterion("note in", values, "note");
            return (criteria) this;
        }

        public criteria andnotenotin(list<string> values) {
            addcriterion("note not in", values, "note");
            return (criteria) this;
        }

        public criteria andnotebetween(string value1, string value2) {
            addcriterion("note between", value1, value2, "note");
            return (criteria) this;
        }

        public criteria andnotenotbetween(string value1, string value2) {
            addcriterion("note not between", value1, value2, "note");
            return (criteria) this;
        }
    }

    public static class criteria extends generatedcriteria {

        protected criteria() {
            super();
        }
    }

    public static class criterion {
        private string condition;

        private object value;

        private object secondvalue;

        private boolean novalue;

        private boolean singlevalue;

        private boolean betweenvalue;

        private boolean listvalue;

        private string typehandler;

        public string getcondition() {
            return condition;
        }

        public object getvalue() {
            return value;
        }

        public object getsecondvalue() {
            return secondvalue;
        }

        public boolean isnovalue() {
            return novalue;
        }

        public boolean issinglevalue() {
            return singlevalue;
        }

        public boolean isbetweenvalue() {
            return betweenvalue;
        }

        public boolean islistvalue() {
            return listvalue;
        }

        public string gettypehandler() {
            return typehandler;
        }

        protected criterion(string condition) {
            super();
            this.condition = condition;
            this.typehandler = null;
            this.novalue = true;
        }

        protected criterion(string condition, object value, string typehandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.typehandler = typehandler;
            if (value instanceof list<?>) {
                this.listvalue = true;
            } else {
                this.singlevalue = true;
            }
        }

        protected criterion(string condition, object value) {
            this(condition, value, null);
        }

        protected criterion(string condition, object value, object secondvalue, string typehandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.secondvalue = secondvalue;
            this.typehandler = typehandler;
            this.betweenvalue = true;
        }

        protected criterion(string condition, object value, object secondvalue) {
            this(condition, value, secondvalue, null);
        }
    }
}

user.java

package com.cyb.ssm.po;

import java.util.date;

public class user {
    private integer id;

    private string username;

    private date birthday;

    private string sex;

    private string address;

    public integer getid() {
        return id;
    }

    public void setid(integer id) {
        this.id = id;
    }

    public string getusername() {
        return username;
    }

    public void setusername(string username) {
        this.username = username == null ? null : username.trim();
    }

    public date getbirthday() {
        return birthday;
    }

    public void setbirthday(date birthday) {
        this.birthday = birthday;
    }

    public string getsex() {
        return sex;
    }

    public void setsex(string sex) {
        this.sex = sex == null ? null : sex.trim();
    }

    public string getaddress() {
        return address;
    }

    public void setaddress(string address) {
        this.address = address == null ? null : address.trim();
    }
}

userexample.java

package com.cyb.ssm.po;

import java.util.arraylist;
import java.util.date;
import java.util.iterator;
import java.util.list;

public class userexample {
    protected string orderbyclause;

    protected boolean distinct;

    protected list<criteria> oredcriteria;

    public userexample() {
        oredcriteria = new arraylist<criteria>();
    }

    public void setorderbyclause(string orderbyclause) {
        this.orderbyclause = orderbyclause;
    }

    public string getorderbyclause() {
        return orderbyclause;
    }

    public void setdistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public boolean isdistinct() {
        return distinct;
    }

    public list<criteria> getoredcriteria() {
        return oredcriteria;
    }

    public void or(criteria criteria) {
        oredcriteria.add(criteria);
    }

    public criteria or() {
        criteria criteria = createcriteriainternal();
        oredcriteria.add(criteria);
        return criteria;
    }

    public criteria createcriteria() {
        criteria criteria = createcriteriainternal();
        if (oredcriteria.size() == 0) {
            oredcriteria.add(criteria);
        }
        return criteria;
    }

    protected criteria createcriteriainternal() {
        criteria criteria = new criteria();
        return criteria;
    }

    public void clear() {
        oredcriteria.clear();
        orderbyclause = null;
        distinct = false;
    }

    protected abstract static class generatedcriteria {
        protected list<criterion> criteria;

        protected generatedcriteria() {
            super();
            criteria = new arraylist<criterion>();
        }

        public boolean isvalid() {
            return criteria.size() > 0;
        }

        public list<criterion> getallcriteria() {
            return criteria;
        }

        public list<criterion> getcriteria() {
            return criteria;
        }

        protected void addcriterion(string condition) {
            if (condition == null) {
                throw new runtimeexception("value for condition cannot be null");
            }
            criteria.add(new criterion(condition));
        }

        protected void addcriterion(string condition, object value, string property) {
            if (value == null) {
                throw new runtimeexception("value for " + property + " cannot be null");
            }
            criteria.add(new criterion(condition, value));
        }

        protected void addcriterion(string condition, object value1, object value2, string property) {
            if (value1 == null || value2 == null) {
                throw new runtimeexception("between values for " + property + " cannot be null");
            }
            criteria.add(new criterion(condition, value1, value2));
        }

        protected void addcriterionforjdbcdate(string condition, date value, string property) {
            if (value == null) {
                throw new runtimeexception("value for " + property + " cannot be null");
            }
            addcriterion(condition, new java.sql.date(value.gettime()), property);
        }

        protected void addcriterionforjdbcdate(string condition, list<date> values, string property) {
            if (values == null || values.size() == 0) {
                throw new runtimeexception("value list for " + property + " cannot be null or empty");
            }
            list<java.sql.date> datelist = new arraylist<java.sql.date>();
            iterator<date> iter = values.iterator();
            while (iter.hasnext()) {
                datelist.add(new java.sql.date(iter.next().gettime()));
            }
            addcriterion(condition, datelist, property);
        }

        protected void addcriterionforjdbcdate(string condition, date value1, date value2, string property) {
            if (value1 == null || value2 == null) {
                throw new runtimeexception("between values for " + property + " cannot be null");
            }
            addcriterion(condition, new java.sql.date(value1.gettime()), new java.sql.date(value2.gettime()), property);
        }

        public criteria andidisnull() {
            addcriterion("id is null");
            return (criteria) this;
        }

        public criteria andidisnotnull() {
            addcriterion("id is not null");
            return (criteria) this;
        }

        public criteria andidequalto(integer value) {
            addcriterion("id =", value, "id");
            return (criteria) this;
        }

        public criteria andidnotequalto(integer value) {
            addcriterion("id <>", value, "id");
            return (criteria) this;
        }

        public criteria andidgreaterthan(integer value) {
            addcriterion("id >", value, "id");
            return (criteria) this;
        }

        public criteria andidgreaterthanorequalto(integer value) {
            addcriterion("id >=", value, "id");
            return (criteria) this;
        }

        public criteria andidlessthan(integer value) {
            addcriterion("id <", value, "id");
            return (criteria) this;
        }

        public criteria andidlessthanorequalto(integer value) {
            addcriterion("id <=", value, "id");
            return (criteria) this;
        }

        public criteria andidin(list<integer> values) {
            addcriterion("id in", values, "id");
            return (criteria) this;
        }

        public criteria andidnotin(list<integer> values) {
            addcriterion("id not in", values, "id");
            return (criteria) this;
        }

        public criteria andidbetween(integer value1, integer value2) {
            addcriterion("id between", value1, value2, "id");
            return (criteria) this;
        }

        public criteria andidnotbetween(integer value1, integer value2) {
            addcriterion("id not between", value1, value2, "id");
            return (criteria) this;
        }

        public criteria andusernameisnull() {
            addcriterion("username is null");
            return (criteria) this;
        }

        public criteria andusernameisnotnull() {
            addcriterion("username is not null");
            return (criteria) this;
        }

        public criteria andusernameequalto(string value) {
            addcriterion("username =", value, "username");
            return (criteria) this;
        }

        public criteria andusernamenotequalto(string value) {
            addcriterion("username <>", value, "username");
            return (criteria) this;
        }

        public criteria andusernamegreaterthan(string value) {
            addcriterion("username >", value, "username");
            return (criteria) this;
        }

        public criteria andusernamegreaterthanorequalto(string value) {
            addcriterion("username >=", value, "username");
            return (criteria) this;
        }

        public criteria andusernamelessthan(string value) {
            addcriterion("username <", value, "username");
            return (criteria) this;
        }

        public criteria andusernamelessthanorequalto(string value) {
            addcriterion("username <=", value, "username");
            return (criteria) this;
        }

        public criteria andusernamelike(string value) {
            addcriterion("username like", value, "username");
            return (criteria) this;
        }

        public criteria andusernamenotlike(string value) {
            addcriterion("username not like", value, "username");
            return (criteria) this;
        }

        public criteria andusernamein(list<string> values) {
            addcriterion("username in", values, "username");
            return (criteria) this;
        }

        public criteria andusernamenotin(list<string> values) {
            addcriterion("username not in", values, "username");
            return (criteria) this;
        }

        public criteria andusernamebetween(string value1, string value2) {
            addcriterion("username between", value1, value2, "username");
            return (criteria) this;
        }

        public criteria andusernamenotbetween(string value1, string value2) {
            addcriterion("username not between", value1, value2, "username");
            return (criteria) this;
        }

        public criteria andbirthdayisnull() {
            addcriterion("birthday is null");
            return (criteria) this;
        }

        public criteria andbirthdayisnotnull() {
            addcriterion("birthday is not null");
            return (criteria) this;
        }

        public criteria andbirthdayequalto(date value) {
            addcriterionforjdbcdate("birthday =", value, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaynotequalto(date value) {
            addcriterionforjdbcdate("birthday <>", value, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaygreaterthan(date value) {
            addcriterionforjdbcdate("birthday >", value, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaygreaterthanorequalto(date value) {
            addcriterionforjdbcdate("birthday >=", value, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaylessthan(date value) {
            addcriterionforjdbcdate("birthday <", value, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaylessthanorequalto(date value) {
            addcriterionforjdbcdate("birthday <=", value, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdayin(list<date> values) {
            addcriterionforjdbcdate("birthday in", values, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaynotin(list<date> values) {
            addcriterionforjdbcdate("birthday not in", values, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaybetween(date value1, date value2) {
            addcriterionforjdbcdate("birthday between", value1, value2, "birthday");
            return (criteria) this;
        }

        public criteria andbirthdaynotbetween(date value1, date value2) {
            addcriterionforjdbcdate("birthday not between", value1, value2, "birthday");
            return (criteria) this;
        }

        public criteria andsexisnull() {
            addcriterion("sex is null");
            return (criteria) this;
        }

        public criteria andsexisnotnull() {
            addcriterion("sex is not null");
            return (criteria) this;
        }

        public criteria andsexequalto(string value) {
            addcriterion("sex =", value, "sex");
            return (criteria) this;
        }

        public criteria andsexnotequalto(string value) {
            addcriterion("sex <>", value, "sex");
            return (criteria) this;
        }

        public criteria andsexgreaterthan(string value) {
            addcriterion("sex >", value, "sex");
            return (criteria) this;
        }

        public criteria andsexgreaterthanorequalto(string value) {
            addcriterion("sex >=", value, "sex");
            return (criteria) this;
        }

        public criteria andsexlessthan(string value) {
            addcriterion("sex <", value, "sex");
            return (criteria) this;
        }

        public criteria andsexlessthanorequalto(string value) {
            addcriterion("sex <=", value, "sex");
            return (criteria) this;
        }

        public criteria andsexlike(string value) {
            addcriterion("sex like", value, "sex");
            return (criteria) this;
        }

        public criteria andsexnotlike(string value) {
            addcriterion("sex not like", value, "sex");
            return (criteria) this;
        }

        public criteria andsexin(list<string> values) {
            addcriterion("sex in", values, "sex");
            return (criteria) this;
        }

        public criteria andsexnotin(list<string> values) {
            addcriterion("sex not in", values, "sex");
            return (criteria) this;
        }

        public criteria andsexbetween(string value1, string value2) {
            addcriterion("sex between", value1, value2, "sex");
            return (criteria) this;
        }

        public criteria andsexnotbetween(string value1, string value2) {
            addcriterion("sex not between", value1, value2, "sex");
            return (criteria) this;
        }

        public criteria andaddressisnull() {
            addcriterion("address is null");
            return (criteria) this;
        }

        public criteria andaddressisnotnull() {
            addcriterion("address is not null");
            return (criteria) this;
        }

        public criteria andaddressequalto(string value) {
            addcriterion("address =", value, "address");
            return (criteria) this;
        }

        public criteria andaddressnotequalto(string value) {
            addcriterion("address <>", value, "address");
            return (criteria) this;
        }

        public criteria andaddressgreaterthan(string value) {
            addcriterion("address >", value, "address");
            return (criteria) this;
        }

        public criteria andaddressgreaterthanorequalto(string value) {
            addcriterion("address >=", value, "address");
            return (criteria) this;
        }

        public criteria andaddresslessthan(string value) {
            addcriterion("address <", value, "address");
            return (criteria) this;
        }

        public criteria andaddresslessthanorequalto(string value) {
            addcriterion("address <=", value, "address");
            return (criteria) this;
        }

        public criteria andaddresslike(string value) {
            addcriterion("address like", value, "address");
            return (criteria) this;
        }

        public criteria andaddressnotlike(string value) {
            addcriterion("address not like", value, "address");
            return (criteria) this;
        }

        public criteria andaddressin(list<string> values) {
            addcriterion("address in", values, "address");
            return (criteria) this;
        }

        public criteria andaddressnotin(list<string> values) {
            addcriterion("address not in", values, "address");
            return (criteria) this;
        }

        public criteria andaddressbetween(string value1, string value2) {
            addcriterion("address between", value1, value2, "address");
            return (criteria) this;
        }

        public criteria andaddressnotbetween(string value1, string value2) {
            addcriterion("address not between", value1, value2, "address");
            return (criteria) this;
        }
    }

    public static class criteria extends generatedcriteria {

        protected criteria() {
            super();
        }
    }

    public static class criterion {
        private string condition;

        private object value;

        private object secondvalue;

        private boolean novalue;

        private boolean singlevalue;

        private boolean betweenvalue;

        private boolean listvalue;

        private string typehandler;

        public string getcondition() {
            return condition;
        }

        public object getvalue() {
            return value;
        }

        public object getsecondvalue() {
            return secondvalue;
        }

        public boolean isnovalue() {
            return novalue;
        }

        public boolean issinglevalue() {
            return singlevalue;
        }

        public boolean isbetweenvalue() {
            return betweenvalue;
        }

        public boolean islistvalue() {
            return listvalue;
        }

        public string gettypehandler() {
            return typehandler;
        }

        protected criterion(string condition) {
            super();
            this.condition = condition;
            this.typehandler = null;
            this.novalue = true;
        }

        protected criterion(string condition, object value, string typehandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.typehandler = typehandler;
            if (value instanceof list<?>) {
                this.listvalue = true;
            } else {
                this.singlevalue = true;
            }
        }

        protected criterion(string condition, object value) {
            this(condition, value, null);
        }

        protected criterion(string condition, object value, object secondvalue, string typehandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.secondvalue = secondvalue;
            this.typehandler = typehandler;
            this.betweenvalue = true;
        }

        protected criterion(string condition, object value, object secondvalue) {
            this(condition, value, secondvalue, null);
        }
    }
}

com.cyb.ssm.service

路径:src/main/java

itemservice.java

package com.cyb.ssm.service;

import java.util.list;

import com.cyb.ssm.po.item;

public interface itemservice {
    list<item> queryitemlist();
}

itemserviceimpl.java

package com.cyb.ssm.service;

import java.util.list;

import org.springframework.beans.factory.annotation.autowired;
import org.springframework.stereotype.service;

import com.cyb.ssm.mapper.itemmapper;
import com.cyb.ssm.po.item;
import com.cyb.ssm.po.itemexample;
import com.cyb.ssm.po.itemexample.criteria;
@service
public class itemserviceimpl implements itemservice {

    @autowired
    private itemmapper mapper;
    @override
    public list<item> queryitemlist() {
        //使用逆向工程代码完成持久层查询
        itemexample example=new itemexample();
//        criteria criteria = example.createcriteria();
//        criteria.andidequalto(1);
        return mapper.selectbyexample(example);
    }
}

web.xml

路径:src/main/webapp/web-inf/web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <!-- 配置前端控制器加载spring子容器 -->
    <servlet>
        <servlet-name>ssm</servlet-name>
        <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>
        <init-param>
            <param-name>contextconfiglocation</param-name>
            <param-value>classpath:spring/springmvc.xml</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>ssm</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <!-- 配置contextloaderlistener监听器加载spring父容器 -->
    <context-param>
        <param-name>contextconfiglocation</param-name>
        <param-value>classpath:spring/applicationcontext-*.xml</param-value>
    </context-param>
    <!-- 监听器 -->
    <listener>
        <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>
    </listener>
</web-app>

item-list.jsp

路径:src/main/webapp/web-inf/jsp/item/item-list.jsp

<%@ page language="java" contenttype="text/html; charset=utf-8"
    pageencoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>查询商品列表</title>
</head>
<body> 
<form action="${pagecontext.request.contextpath }/itemlist.do" method="post">
查询条件:
<table width="100%" border=1>
<tr>
<td><input type="submit" value="查询"/></td>
</tr>
</table>
商品列表:
<table width="100%" border=1>
<tr>
    <td>商品名称</td>
    <td>商品价格</td>
    <td>生产日期</td>
    <td>商品描述</td>
    <td>操作</td>
</tr>
<c:foreach items="${itemlist }" var="item" varstatus="status">
<tr>
    <td><input type="text" name="itemlist[${status.index }].name" value="${item.name }"/></td>
    <td>${item.price }</td>
    <td><fmt:formatdate value="${item.createtime}" pattern="yyyy-mm-dd hh:mm:ss"/></td>
    <td>${item.detail }</td>
    
    <td><a href="${pagecontext.request.contextpath }/itemedit.do?id=${item.id}">修改</a></td>

</tr>
</c:foreach>

</table>
</form>
</body>

</html>

 项目结构图

 

 

 

 数据库表结构

 

 运行

 

 项目源码

 

 

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网