SSH整合详解

SSH项目整合

一、maven工程

pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.zengqingfa.ssh</groupId>
    <artifactId>ssh</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>


    <!-- 定义版本常量 -->
    <properties>
        <spring.version>4.2.4.RELEASE</spring.version>
        <struts.version>2.3.24</struts.version>
        <hibernate.version>5.0.7.Final</hibernate.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>${struts.version}</version>
            <!-- 排除依赖 -->
            <exclusions>
                <exclusion>
                    <artifactId>javassist</artifactId>
                    <groupId>javassist</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <!-- 第一个原则:第一申明者优先 -->

        <!-- 引入spring-beans-4.2.2 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.2.RELEASE</version>
        </dependency>
        <!-- 引入 spring-beans-3.0.5 -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
            <version>${struts.version}</version>
        </dependency>
        <!-- 第二个原则:路径近者优先 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson
        fastjson  阿里巴巴
        -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-json-plugin -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-json-plugin</artifactId>
            <version>2.3.24</version>
        </dependency>


        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>
    </dependencies>

    <!-- 版本锁定  -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <!-- 配置了很多插件 -->
        <plugins>
            <!-- 编译插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <!-- tomcat插件 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <port>8080</port>
                    <path>/</path>
                    <uriEncoding>UTF-8</uriEncoding>
                    <server>tomcat7</server>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

二、domain

1、Customer.java

package com.zengqingfa.domain;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:22
 *
 */

import java.io.Serializable;

/**
 * PO(Persistence Object)持久化类
 * 7个规范
 * 1. 公有类
 * 2. 公有无参构造
 * 3. 私有属性
 * 4. 公有的getter与setter
 * 5. 实现java.io.Serializable接口
 * 6. 不能用final修饰
 * 7. 如果是基础类型,要使用它的包装类
 */
public class Customer implements Serializable {

    private Long custId;    //id
    private String custName;    //名字
    private Long custUserId;    //用户id
    private Long custCreateId;
    private String custIndustry;
    private String custLevel;
    private String custLinkman;
    private String custPhone;
    private String custMobile;

    public Long getCustId() {
        return custId;
    }

    public void setCustId(Long custId) {
        this.custId = custId;
    }

    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    public Long getCustUserId() {
        return custUserId;
    }

    public void setCustUserId(Long custUserId) {
        this.custUserId = custUserId;
    }

    public Long getCustCreateId() {
        return custCreateId;
    }

    public void setCustCreateId(Long custCreateId) {
        this.custCreateId = custCreateId;
    }

    public String getCustIndustry() {
        return custIndustry;
    }

    public void setCustIndustry(String custIndustry) {
        this.custIndustry = custIndustry;
    }

    public String getCustLevel() {
        return custLevel;
    }

    public void setCustLevel(String custLevel) {
        this.custLevel = custLevel;
    }

    public String getCustLinkman() {
        return custLinkman;
    }

    public void setCustLinkman(String custLinkman) {
        this.custLinkman = custLinkman;
    }

    public String getCustPhone() {
        return custPhone;
    }

    public void setCustPhone(String custPhone) {
        this.custPhone = custPhone;
    }

    public String getCustMobile() {
        return custMobile;
    }

    public void setCustMobile(String custMobile) {
        this.custMobile = custMobile;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "custId=" + custId +
                ", custName='" + custName + '\'' +
                ", custUserId=" + custUserId +
                ", custCreateId=" + custCreateId +
                ", custIndustry='" + custIndustry + '\'' +
                ", custLevel='" + custLevel + '\'' +
                ", custLinkman='" + custLinkman + '\'' +
                ", custPhone='" + custPhone + '\'' +
                ", custMobile='" + custMobile + '\'' +
                '}';
    }
}


三、action

1、CustomerAction.java

package com.zengqingfa.action;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:23
 *
 */

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Result;
import com.zengqingfa.domain.Customer;
import com.zengqingfa.service.CustomerService;
import net.sf.json.JSONObject;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class CustomerAction {

    private Customer customer;

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public CustomerService getCustomerService() {
        return customerService;
    }

    public void setCustomerService(CustomerService customerService) {
        this.customerService = customerService;
    }

    @Autowired
    private CustomerService customerService;

    public String findAll() {
        List<Customer> list = customerService.findAll();
        ServletActionContext.getContext().put("list", list);
        return "list";
    }


}

2、TestCustomerJson.java

package com.zengqingfa.action;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  19:18
 *
 */

import com.opensymphony.xwork2.ActionSupport;
import com.zengqingfa.domain.Customer;
import com.zengqingfa.service.CustomerService;
import net.sf.json.JSONObject;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TestCustomerJson extends ActionSupport {
    private String result;

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public CustomerService getCustomerService() {
        return customerService;
    }

    public void setCustomerService(CustomerService customerService) {
        this.customerService = customerService;
    }

    private List<Customer> list = new ArrayList<>();

    public List<Customer> getList() {
        return list;
    }

    public void setList(List<Customer> list) {
        this.list = list;
    }


    @Autowired
    private CustomerService customerService;

    //使用struts2返回json数据,需要在struts.xml配置要返回的数据
    public String execute() {
        list = customerService.findAll();
        return "success";
    }

    //测试返回json数据方式一
    public String testJson() {
        try {
            List<Customer> list = customerService.findAll();
            //将数据存储在map里,再转换成json类型数据,也可以自己手动构造json类型数据
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("list", list);
            JSONObject json = JSONObject.fromObject(map);//将map对象转换成json类型数据
            result = json.toString();//给result赋值,传递给页面
        } catch (Exception e) {
            e.printStackTrace();
        }
        return SUCCESS;
    }

    //原生方式返回json数据
    public void testJson02() {
        try {
            HttpServletResponse response = ServletActionContext.getResponse();
            /*
             * 在调用getWriter之前未设置编码(既调用setContentType或者setCharacterEncoding方法设置编码),
             * HttpServletResponse则会返回一个用默认的编码(既ISO-8859-1)编码的PrintWriter实例。这样就会
             * 造成中文乱码。而且设置编码时必须在调用getWriter之前设置,不然是无效的。
             * */
            response.setContentType("text/html;charset=utf-8");
            //response.setCharacterEncoding("UTF-8");
            PrintWriter out = response.getWriter();
            List<Customer> list = customerService.findAll();
            //将数据存储在map里,再转换成json类型数据,也可以自己手动构造json类型数据
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("list", list);
            JSONObject json = JSONObject.fromObject(map);//将map对象转换成json类型数据
            out.print(json.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

四、service

1、service接口

package com.zengqingfa.service;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:22
 *
 */

import com.zengqingfa.domain.Customer;

import java.util.List;

public interface CustomerService {
    List<Customer> findAll();
}

2、service实现

package com.zengqingfa.service.impl;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:23
 *
 */

import com.zengqingfa.dao.CustomerDao;
import com.zengqingfa.domain.Customer;
import com.zengqingfa.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {

    //注入dao
    @Autowired
    private CustomerDao customerDao;

    @Override
    public List<Customer> findAll() {
        return customerDao.findAll();
    }
}

五、dao

1、dao接口

package com.zengqingfa.dao;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:21
 *
 */

import com.zengqingfa.domain.Customer;

import java.util.List;

public interface CustomerDao {

    List<Customer> findAll();

    Customer findCustomerById(long custId);

    void save(Customer customer);
}

2、dao实现

package com.zengqingfa.dao.impl;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:32
 *
 */

import com.zengqingfa.dao.CustomerDao;
import com.zengqingfa.domain.Customer;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;


public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {


    @Override
    public List<Customer> findAll() {
        return (List<Customer>) this.getHibernateTemplate().find("from Customer");

    }

    @Override
    public Customer findCustomerById(long custId) {
        return this.getHibernateTemplate().get(Customer.class, custId);

    }

    @Override
    public void save(Customer customer) {
        this.getHibernateTemplate().save(customer);
    }
}

六、配置文件

1、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 -->
    <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>
    <!-- openSessionInView -->
    <filter>
        <filter-name>openSessionInView</filter-name>
        <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>openSessionInView</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- struts -->
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


</web-app>

2、struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts
        PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
        "http://struts.apache.org/dtds/struts-2.3.dtd" >

<struts>
    <!--,json-default-->
    <package name="default" namespace="/" extends="struts-default,json-default">

        <!--    <action name="customer_*" class="com.zengqingfa.action.CustomerAction" method="{1}">
                <result name="list">/list.jsp</result>
            </action>-->
        <action name="findAll" class="com.zengqingfa.action.CustomerAction" method="findAll">
            <result name="list">/list.jsp</result>
        </action>

        <action name="test_json" method="testJson" class="com.zengqingfa.action.TestCustomerJson">
            <result name="fail"></result>
            <!-- 返回json类型数据 -->
            <result type="json">
                <!-- result是action中设置的变量名,也是页面需要返回的数据,
                该变量必须有setter和getter方法 -->
                <param name="root">result</param>
            </result>
        </action>

        <action name="test_json2" class="com.zengqingfa.action.TestCustomerJson" method="testJson02"></action>


    </package>
</struts>

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

    <!--开启注解扫描-->
    <context:component-scan base-package="com.zengqingfa"></context:component-scan>

    <!-- 数据源 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssh?characterEncoding=utf-8"></property>
        <property name="user" value="root"></property>
        <property name="password" value="root"/>
    </bean>

    <!-- sessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
        <!--<property name="mappingLocations" value="classpath:com/zengqingfa/domain/Customer.hbm.xml"></property>-->
    </bean>

    <bean id="customerDao" class="com.zengqingfa.dao.impl.CustomerDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

</beans>

4、hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" >
<hibernate-configuration>

    <session-factory>
        <!-- 方言 -->
        <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>

        <!--是否显示sql-->
        <property name="show_sql">true</property>

        <!--是否格式化sql-->
        <property name="format_sql">false</property>

        <property name="hbm2ddl.auto">update</property>

        <!-- 懒加载 -->
        <property name="hibernate.enable_lazy_load_no_trans">true</property>

        <!-- 实体类的验证 -->
        <property name="javax.persistence.validation.mode">none</property>

        <!--引入配置文件-->
        <mapping resource="com/zengqingfa/domain/Customer.hbm.xml"></mapping>
    </session-factory>
</hibernate-configuration>

5、Customer.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
    <class name="com.zengqingfa.domain.Customer" table="customer">

        <id name="custId" type="java.lang.Long">
            <column name="cust_id"/>
            <!-- 6种生成策略  : identity,native,sequence,uuid,increment, assigned  -->
        </id>

        <property name="custName" type="string">
            <column name="cust_name" length="32" not-null="true"></column>
        </property>
        <property name="custUserId" column="cust_user_id"></property>
        <property name="custCreateId" column="cust_create_id"></property>
        <property name="custIndustry" column="cust_industry"></property>
        <property name="custLevel" column="cust_level"></property>

        <property name="custLinkman" type="string">
            <column name="cust_linkman" length="64"></column>
        </property>
        <property name="custPhone" type="string">
            <column name="cust_phone" length="64"></column>
        </property>
        <property name="custMobile" type="string">
            <column name="cust_mobile" length="16"></column>
        </property>

    </class>
</hibernate-mapping>

6、log4j.properties

log4j.rootLogger=DEBUG,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-d{yyyy-MM-ddHH:mm:ss,SSS} [%t] [%c]-[%p] %m%n
七、测试

1、TestMysql

package com.zengqingfa;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:44
 *
 */

import com.zengqingfa.dao.CustomerDao;
import com.zengqingfa.domain.Customer;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class TestMysql {

    @Test
    public void TestFindAll() {
        //获取spring容器
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring/applicationContext.xml");
        CustomerDao customerDao = (CustomerDao) applicationContext.getBean("customerDao");
        List<Customer> customers = customerDao.findAll();
        for (Customer customer : customers) {
            System.out.println(customer);
        }
    }

    @Test
    public void TestFindCustomerById() {
        //获取spring容器
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring/applicationContext.xml");
        CustomerDao customerDao = (CustomerDao) applicationContext.getBean("customerDao");
        Customer customer = customerDao.findCustomerById(11l);
        System.out.println(customer);
    }


}

2、TestSSH:与junit进行整合

package com.zengqingfa;

/*
 *  @ author  zengqingfa
 *  @ created in    2019/2/17  16:44
 *
 */

import com.zengqingfa.dao.CustomerDao;
import com.zengqingfa.domain.Customer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/applicationContext.xml")
public class TestSSH {

    @Autowired
    private CustomerDao customerDao;

    @Test
    public void TestFindAll() {
        List<Customer> customers = customerDao.findAll();
        for (Customer customer : customers) {
            System.out.println(customer);
        }
    }

    @Test
    public void TestFindCustomerById() {
        Customer customer = customerDao.findCustomerById(11l);
        System.out.println(customer);
    }

}


八、页面

list.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html 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>Insert title here</title>
</head>
<body>
<c:forEach items="${list }" var="customer">
    ${customer.custId } -> ${customer.custName } <br />
</c:forEach>
</body>
</html>
九、展示

1、http://localhost:8080/findAll.action

2、http://localhost:8080/test_json.action

"{\"list\":[{\"custCreateId\":0,\"custId\":11,\"custIndustry\":\"\",\"custLevel\":\"\",\"custLinkman\":\"\",\"custMobile\":\"\",\"custName\":\"22\",\"custPhone\":\"\",\"custUserId\":22},{\"custCreateId\":0,\"custId\":33,\"custIndustry\":\"dd\",\"custLevel\":\"\",\"custLinkman\":\"\",\"custMobile\":\"\",\"custName\":\"bb\",\"custPhone\":\"\",\"custUserId\":0},{\"custCreateId\":0,\"custId\":55,\"custIndustry\":\"\",\"custLevel\":\"\",\"custLinkman\":\"\",\"custMobile\":\"\",\"custName\":\"\",\"custPhone\":\"\",\"custUserId\":0},{\"custCreateId\":0,\"custId\":66,\"custIndustry\":\"\",\"custLevel\":\"\",\"custLinkman\":\"\",\"custMobile\":\"\",\"custName\":\"77\",\"custPhone\":\"\",\"custUserId\":0}]}"

3、http://localhost:8080/test_json2.action

{"list":[{"custCreateId":0,"custId":11,"custIndustry":"","custLevel":"","custLinkman":"","custMobile":"","custName":"22","custPhone":"","custUserId":22},{"custCreateId":0,"custId":33,"custIndustry":"dd","custLevel":"","custLinkman":"","custMobile":"","custName":"bb","custPhone":"","custUserId":0},{"custCreateId":0,"custId":55,"custIndustry":"","custLevel":"","custLinkman":"","custMobile":"","custName":"","custPhone":"","custUserId":0},{"custCreateId":0,"custId":66,"custIndustry":"","custLevel":"","custLinkman":"","custMobile":"","custName":"77","custPhone":"","custUserId":0}]}
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,029评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,395评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,570评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,535评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,650评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,850评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,006评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,747评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,207评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,536评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,683评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,342评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,964评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,772评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,004评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,401评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,566评论 2 349

推荐阅读更多精彩内容