SSM框架整合之練習篇

来源:https://www.cnblogs.com/haizai/archive/2019/10/13/11668012.html
-Advertisement-
Play Games

SSM的練習 : 1開發環境 資料庫:mysql5.5以上版本。 Jdk:1.7 開發環境:Eclipse mars2 Spring:4.2.4 Mybatis:3.2.7 Tomcat:7 2資料庫 資料庫使用mysql 資料庫。 1、創建crm資料庫 2、將參考資料中的sql腳本導入到資料庫中 ... ...


SSM的練習 :
        1開發環境
        資料庫:mysql5.5以上版本。
        Jdk:1.7
        開發環境:Eclipse mars2
        Spring:4.2.4
        Mybatis:3.2.7
        Tomcat:7
        2資料庫
        資料庫使用mysql 資料庫。

        1、創建crm資料庫
        2、將參考資料中的sql腳本導入到資料庫中

        3工程搭建
        工程使用Springmvc、spring、mybatis框架整合完成。

        Dao層:SqlMapConfig.xml(空)
                applicationContext-dao.xml:資料庫連接池、SqlSessionFactory、Mapper的掃描器。
        Service層:
            配置包掃描器,掃描所有帶@Service註解的類。事務管理器、切麵。
        表現層:
                Springmvc.xml:包掃描器@Controller、配置註解驅動、視圖解析器。
                Jsp:bootstrap
        Web.xml:配置spring監聽器,前端控制器。
        3.1SqlMapConfig.xml
        <?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">

        <configuration>

        </configuration>
        3.2applicationContext-dao.xml
        <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
            xmlns:context="http://www.springframework.org/schema/context"
            xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
            xmlns:task="http://www.springframework.org/schema/task" 
            xsi:schemaLocation="http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
                http://www.springframework.org/schema/mvc 
                http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd 
                http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-4.2.xsd 
                http://www.springframework.org/schema/aop 
                http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
                http://www.springframework.org/schema/tx 
                http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
                http://www.springframework.org/schema/task
                http://www.springframework.org/schema/task/spring-task-4.2.xsd">

            <!-- 配置 讀取properties文件 jdbc.properties -->
            <context:property-placeholder location="classpath:jdbc.properties" />

            <!-- 配置 數據源 -->
            <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
                <!-- 驅動 -->
                <property name="driverClassName" value="${jdbc.driver}" />
                <!-- url -->
                <property name="url" value="${jdbc.url}" />
                <!-- 用戶名 -->
                <property name="username" value="${jdbc.username}" />
                <!-- 密碼 -->
                <property name="password" value="${jdbc.password}" />
            </bean>

            <!-- 配置 Mybatis的工廠 -->
            <bean class="org.mybatis.spring.SqlSessionFactoryBean">
                <!-- 數據源 -->
                <property name="dataSource" ref="dataSource" />
                <!-- 配置Mybatis的核心 配置文件所在位置 -->
                <property name="configLocation" value="classpath:SqlMapConfig.xml" />
                <!-- 配置pojo別名 -->
                <property name="typeAliasesPackage" value="cn.baidu.core.bean"></property>
            </bean>

            <!-- 配置 1:原始Dao開發 介面實現類 Mapper.xml 三個 2:介面開發 介面 不寫實現類 Mapper.xml 二個 (UserDao、ProductDao 
                、BrandDao。。。。。。。) 3:介面開發、並支持掃描 cn.baidu.core.dao(UserDao。。。。。) 寫在此包下即可被掃描到 -->
            <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
                <property name="basePackage" value="cn.baidu.core.dao" />
            </bean>

        </beans>

        Jdbc.properties
        jdbc.driver=com.mysql.jdbc.Driver
        jdbc.url=jdbc:mysql://localhost:3306/crm?characterEncoding=utf-8
        jdbc.username=root
        jdbc.password=root
        3.3applicationContext-service.xml
        <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
            xmlns:context="http://www.springframework.org/schema/context"
            xmlns:aop="http://www.springframework.org/schema/aop" 
            xmlns:tx="http://www.springframework.org/schema/tx"
            xmlns:task="http://www.springframework.org/schema/task"
            xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
            xsi:schemaLocation="http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
                http://www.springframework.org/schema/mvc 
                http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd 
                http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-4.2.xsd 
                http://www.springframework.org/schema/aop 
                http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
                http://www.springframework.org/schema/tx 
                http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
                http://www.springframework.org/schema/task
                http://www.springframework.org/schema/task/spring-task-4.2.xsd
                http://code.alibabatech.com/schema/dubbo        
                http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
                
                
                <!-- 配置  掃描   @Service -->
                <context:component-scan base-package="cn.baidu.core.service"/>
                
                
                
        </beans>

        3.4applicationContext-trans.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
            xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
            <!-- 事務管理器 -->
            <bean id="transactionManager"
                class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                <!-- 數據源 -->
                <property name="dataSource" ref="dataSource" />
            </bean>
            <!-- 通知 -->
            <tx:advice id="txAdvice" transaction-manager="transactionManager">
                <tx:attributes>
                    <!-- 傳播行為 -->
                    <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="update*" propagation="REQUIRED" />
                    <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
                    <tx:method name="select*" propagation="SUPPORTS" read-only="true" />
                    <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
                </tx:attributes>
            </tx:advice>
            <!-- 切麵 -->
            <aop:config>
                <aop:advisor advice-ref="txAdvice"
                    pointcut="execution(* cn.baidu.core.service.*.*(..))" />
            </aop:config>
        </beans>
        3.5Springmvc.xml
        <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
            xmlns:context="http://www.springframework.org/schema/context"
            xmlns:aop="http://www.springframework.org/schema/aop" 
            xmlns:tx="http://www.springframework.org/schema/tx"
            xmlns:task="http://www.springframework.org/schema/task"
            xsi:schemaLocation="http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
                http://www.springframework.org/schema/mvc 
                http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd 
                http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-4.2.xsd 
                http://www.springframework.org/schema/aop 
                http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
                http://www.springframework.org/schema/tx 
                http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
                http://www.springframework.org/schema/task
                http://www.springframework.org/schema/task/spring-task-4.2.xsd">        
                <!-- 載入屬性文件 -->
                <context:property-placeholder location="classpath:resource.properties"/>
                <!-- 配置掃描 器 -->
                <context:component-scan base-package="cn.baidu.core.web.controller"/>
                <!-- 配置處理器映射器  適配器 -->
                <mvc:annotation-driven/>
                
                <!-- 配置視圖解釋器 jsp -->
                <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="prefix" value="/WEB-INF/jsp/"/>
                    <property name="suffix" value=".jsp"/>
                </bean>
                
        </beans>

        3.6Web.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
            <welcome-file-list>
                <welcome-file>customer.action</welcome-file>
            </welcome-file-list>
            <!-- 上下文的位置 -->
            <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:applicationContext-*.xml</param-value>
            </context-param>
            <!-- Spring的監聽器 -->
            <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
            </listener>


            <!-- POST提交過濾器 UTF-8 -->
            <filter>
                <filter-name>encoding</filter-name>
                <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                <init-param>
                    <param-name>encoding</param-name>
                    <param-value>UTF-8</param-value>
                </init-param>
            </filter>

            <filter-mapping>
                <filter-name>encoding</filter-name>
                <url-pattern>*.action</url-pattern>
            </filter-mapping>
            <!-- 前端控制器 -->
            <servlet>
                <servlet-name>crm</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <init-param>
                    <param-name>contextConfigLocation</param-name>
                    <!-- 此處不配置 預設找 /WEB-INF/[servlet-name]-servlet.xml -->
                    <param-value>classpath:springmvc.xml</param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
            </servlet>
            <servlet-mapping>
                <servlet-name>crm</servlet-name>
                <!-- 1:*.do *.action 攔截以.do結尾的請求 (不攔截 jsp png jpg .js .css) 2:/ 攔截所有請求 
                    (不攔截.jsp) 建議使用此種 方式 (攔截 .js.css .png) (放行靜態資源) 3:/* 攔截所有請求(包括.jsp) 此種方式 不建議使用 -->
                <url-pattern>*.action</url-pattern>
            </servlet-mapping>
        </web-app>


        3.7加入jsp及分頁標簽

        Tld文件需要放到WEB-INF目錄下, tomcat的規定。當tomcat啟動時會自動載入。

        Jsp中使用標簽:



        4查詢條件初始化
        4.1需求

        初始化查詢條件下拉列表。

        4.2Sql
        SELECT * from base_dict WHERE dict_type_code='006'
        4.3Dao
        <?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.baidu.crm.dao.BaseDictDao">
            <select id="getBaseDictList" parameterType="string" resultType="BaseDict">
                SELECT * from base_dict WHERE dict_type_code=#{typeCode}
            </select>
        </mapper>

        4.4Service
        @Service
        public class BaseDictServiceImpl implements BaseDictService {

            @Autowired
            private BaseDictDao baseDictDao;
            
            @Override
            public List<BaseDict> getBaseDictList(String typeCode) {
                List<BaseDict> list = baseDictDao.getBaseDictList(typeCode);
                return list;
            }

        }

        4.5Controller












        規則:子容器可以訪問父容器的對象,父容器不能訪問子容器的對象。
        public class CustomerController {
            
            @Autowired
            private BaseDictService baseDictService;
            @Value("${customer.source.code}")
            private String CustomerSourceCode;
            @Value("${customer.industry.code}")
            private String CustomerIndustryCode;
            @Value("${customer.level.code}")
            private String CustomerLevelCode;

            @RequestMapping("/list")
            public String showCustomerList(Model model) {
                //查詢字典表初始化下拉列表
                List<BaseDict> custSourceList = baseDictService.getBaseDictList(CustomerSourceCode);
                List<BaseDict> custIndustryList = baseDictService.getBaseDictList(CustomerIndustryCode);
                List<BaseDict> custLevelList = baseDictService.getBaseDictList(CustomerLevelCode);
                //把列表傳遞給jsp頁面
                model.addAttribute("fromType", custSourceList);
                model.addAttribute("industryType", custIndustryList);
                model.addAttribute("levelType", custLevelList);
                
                return "customer";
            }
        }

        5客戶列表展示
        5.1需求

        展示商品列表,並且可以根據查詢條件過濾查詢結果,並且實現分頁處理。

        5.2Sql
        SELECT
            a.cust_id,
            a.cust_name,
            a.cust_user_id,
            a.cust_create_id,
            b.dict_item_name cust_source,
            c.dict_item_name cust_industry,
            d.dict_item_name cust_level,
            a.cust_linkman,
            a.cust_phone,
            a.cust_mobile,
            a.cust_zipcode,
            a.cust_address,
            a.cust_createtime
        FROM
            customer a
        LEFT JOIN base_dict b ON a.cust_source = b.dict_id
        LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
        LEFT JOIN base_dict d ON a.cust_level = d.dict_id
        WHERE
            cust_name LIKE '%馬%'
        AND cust_source = 6
        AND cust_industry = 2
        AND cust_level = 22

        5.3Dao
        <select id="getCustList" parameterType="QueryVo" resultType="customer">
                SELECT
                    a.cust_id,
                    a.cust_name,
                    a.cust_user_id,
                    a.cust_create_id,
                    b.dict_item_name cust_source,
                    c.dict_item_name cust_industry,
                    d.dict_item_name cust_level,
                    a.cust_linkman,
                    a.cust_phone,
                    a.cust_mobile,
                    a.cust_zipcode,
                    a.cust_address,
                    a.cust_createtime
                FROM
                    customer a
                LEFT JOIN base_dict b ON a.cust_source = b.dict_id
                LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
                LEFT JOIN base_dict d ON a.cust_level = d.dict_id
                <where>
                    <if test="custName!=null and custName!=''">
                        AND    cust_name LIKE '%${custName}%'
                    </if>
                    <if test="custSource!=null and custSource!=''">
                        AND cust_source = #{custSource}
                    </if>
                    <if test="custIndustry!=null and custIndustry!=''">
                        AND cust_industry = #{custIndustry}
                    </if>
                    <if test="custLevel!=null and custLevel!=''">
                        AND cust_level = #{custLevel}
                    </if>
                </where>
                LIMIT #{start},#{rows}
            </select>

        增加count後的dao
        <mapper namespace="com.baidu.crm.dao.CustomerDao">
            
            <sql id="cust_query_where">
                <where>
                    <if test="custName!=null and custName!=''">
                        AND    cust_name LIKE '%${custName}%'
                    </if>
                    <if test="custSource!=null and custSource!=''">
                        AND cust_source = #{custSource}
                    </if>
                    <if test="custIndustry!=null and custIndustry!=''">
                        AND cust_industry = #{custIndustry}
                    </if>
                    <if test="custLevel!=null and custLevel!=''">
                        AND cust_level = #{custLevel}
                    </if>
                </where>
            </sql>
            
            <select id="getCustList" parameterType="QueryVo" resultType="customer">
                SELECT
                    a.cust_id,
                    a.cust_name,
                    a.cust_user_id,
                    a.cust_create_id,
                    b.dict_item_name cust_source,
                    c.dict_item_name cust_industry,
                    d.dict_item_name cust_level,
                    a.cust_linkman,
                    a.cust_phone,
                    a.cust_mobile,
                    a.cust_zipcode,
                    a.cust_address,
                    a.cust_createtime
                FROM
                    customer a
                LEFT JOIN base_dict b ON a.cust_source = b.dict_id
                LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
                LEFT JOIN base_dict d ON a.cust_level = d.dict_id
                <include refid="cust_query_where"/>
                LIMIT #{start},#{rows}
            </select>
            <select id="getCustListCount" parameterType="QueryVo" resultType="int">
                SELECT count(*)
                FROM
                    customer a
                LEFT JOIN base_dict b ON a.cust_source = b.dict_id
                LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
                LEFT JOIN base_dict d ON a.cust_level = d.dict_id
                <include refid="cust_query_where"/>
            </select>
        </mapper>

        5.4Service
        根據查詢條件查詢資料庫得到客戶列表。分頁條件。
        接收查詢條件QueryVo接收,使用page接收頁碼。
        1、通過page計算start。
        2、調用dao查詢客戶列表。
        3、做count處理。計算出此查詢條件中共查詢到多少條記錄。

        返回結果:Page對象。
        條件:QueryVo
        @Service
        public class CustomerServiceImpl implements CustomerService {

            @Autowired
            private CustomerDao customerDao;
            
            @Override
            public Page<Customer> getCustList(QueryVo queryVo) {
        queryVo.setStart((queryVo.getPage() - 1) * queryVo.getRows());
                List<Customer> custList = customerDao.getCustList(queryVo);
                Page<Customer> page = new Page<Customer>();
                //設置客戶列表
                page.setRows(custList);
                page.setPage(queryVo.getPage());
                page.setSize(queryVo.getRows());
                //計算查詢總記錄數
                int total = customerDao.getCustListCount(queryVo);
                page.setTotal(total);
                return page;
            }

        }

        5.5Controller
        5.5.1分析
        1、接收頁面提交的查詢參數:
        保證jsp頁面提交的表單中的input 的name屬性和QueryVo中的屬性一致
        2、調用Service查詢客戶列表
        3、把客戶列表傳遞給頁面。


        @RequestMapping("/list")
            public String showCustomerList(Model model, QueryVo queryVo) throws Exception {
                
                String custName = queryVo.getCustName();
                if (custName != null && !"".equals(custName)) {
                    custName = new String(custName.getBytes("iso8859-1"), "utf-8");
                    queryVo.setCustName(custName);
                }
                //查詢字典表初始化下拉列表
                List<BaseDict> custSourceList = baseDictService.getBaseDictList(CustomerSourceCode);
                List<BaseDict> custIndustryList = baseDictService.getBaseDictList(CustomerIndustryCode);
                List<BaseDict> custLevelList = baseDictService.getBaseDictList(CustomerLevelCode);
                //查詢客戶列表
                Page<Customer> page = customerService.getCustList(queryVo);
                //把page放到request中
                model.addAttribute("page", page);
                
                //把列表傳遞給jsp頁面
                model.addAttribute("fromType", custSourceList);
                model.addAttribute("industryType", custIndustryList);
                model.addAttribute("levelType", custLevelList);
                
                //頁面回顯
                model.addAttribute("custName", queryVo.getCustName());
                model.addAttribute("custSource", queryVo.getCustSource());
                model.addAttribute("custIndustry", queryVo.getCustIndustry());
                model.addAttribute("custLevel", queryVo.getCustLevel());
                
                
                return "customer";
            }


        6修改客戶信息
        6.1需求

        1、點擊客戶列表中的“修改”按鈕彈出客戶信息修改對話框,並初始化客戶信息
        2、點擊“保存修改”按鈕將修改後的結果保存到資料庫中

        6.2展示客戶信息

        6.2.1分析
        請求的url:
        customer/edit.action
        參數:cust_id客戶id
        返回值:響應json數據,直接由Customer轉換而來。需要使用@ResponseBody註解。

        6.2.2Dao層
        根據客戶id查詢客戶信息。
        <select id="getCustomerById" parameterType="long" resultType="customer">
                select * from customer where cust_id = #{custId}
            </select>

        6.2.3Service層
            @Override
            public Customer getCustomerById(long custId) {
                Customer customer = customerDao.getCustomerById(custId);
                return customer;
            }

        6.2.4Controller
        要求返回json數據
        請求的url:
        customer/edit.action
        參數:cust_id客戶id
        返回值:響應json數據
        @RequestMapping("/edit")
            @ResponseBody
            public Customer getCustomerById(Long id) {
                Customer customer = customerService.getCustomerById(id);
                return customer;
            }


        6.3提交修改
        6.3.1分析
        請求的url:customer/update.action
        請求的方法:post
        參數:表單中的數據。
        返回結果:OK

        6.3.2Dao層
        <update id="updateCustomerById" parameterType="customer">
                UPDATE customer
                <set>
                    <if test="cust_name!=null">
                    cust_name=#{cust_name},
                    </if>
                    <if test="cust_user_id!=null">
                    cust_user_id=#{cust_user_id},
                    </if>
                    <if test="cust_create_id!=null">
                    cust_create_id=#{cust_create_id},
                    </if>
                    <if test="cust_source!=null">
                    cust_source=#{cust_source},
                    </if>
                    <if test="cust_industry!=null">
                    cust_industry=#{cust_industry},
                    </if>
                    <if test="cust_level!=null">
                    cust_level=#{cust_level},
                    </if>
                    <if test="cust_linkman!=null">
                    cust_linkman=#{cust_linkman},
                    </if>
                    <if test="cust_phone!=null">
                    cust_phone=#{cust_phone},
                    </if>
                    <if test="cust_mobile!=null">
                    cust_mobile=#{cust_mobile},
                    </if>
                    <if test="cust_zipcode!=null">
                    cust_zipcode=#{cust_zipcode},
                    </if>
                    <if test="cust_address!=null">
                    cust_address=#{cust_address},
                    </if>
                    <if test="cust_createtime!=null">
                    cust_createtime=#{cust_createtime},
                    </if>
                </set>
                WHERE
                    cust_id = #{cust_id}
            </update>
        6.3.3Service層
        @Override
            public void updateCustomerById(Customer customer) {
                customerDao.updateCustomerById(customer);
            }

        6.3.4Controller
        接收參數:Customer接收。
        響應結果:OK字元串。使用@ResponseBody
        請求的url:customer/update.action
        @RequestMapping(value="/update", method=RequestMethod.POST)
            @ResponseBody
            public String updateCustomer(Customer customer) {
                customerService.updateCustomerById(customer);
                //直接向瀏覽器響應字元串需要使用@ResponseBody
                return "OK";
                
            }

        7刪除客戶
        7.1需求

        點擊客戶列表中的刪除按鈕,提示“警告信息”

        點擊確定後刪除用戶信息,並刷新頁面。

        分析:
        請求的url:customer/delete.action

        參數:id(客戶id)
        響應的內容:OK(字元串需要使用@ResponseBody)

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • element.offsetLeft/Top 獲取元素相對於最近的有定位的父元素的坐標,如果沒有有定位的父元素,則是文檔坐標 element.scrollTop/Left 獲取元素滾動捲去的距離 element.offsetWidth/Height 獲取元素的寬度高度(包含邊框) element.c ...
  • 後臺開發人員不擅長前端UI界面,而小型軟體公司沒有專職美工崗位,開發人員只能藉助開源UI框架,復用已有組件,完成用戶操作界面。EasyUI是基於jQuery的UI插件集合體,可幫助開發者輕鬆構建網頁。 官方地址:http://www.jeasyui.com/ 一、引用EasyUI 官網下載EasyU ...
  • 前言 vue.js是一套構建用戶界面的漸進式框架,vue.js的目標是通過儘可能簡單的API實現響應的數據綁定和組合的視圖組件。 vue通過DOM事件操作和指令來進行視圖層和模型層的相互通訊,會為每一處需要動態更新的DOM節點創建一個指令對象。每當一個指令對象觀測的數據變化時,它便會對所綁定的目標節 ...
  • 正值前端組件化開發時代,那麼必然離不開目前最火的構建工具——webpack(grunt,gulp等暫且不談)。說到這裡,剛好有幾個問題: 為什麼運行打包命令之後, 文件可以轉成 文件 為什麼運行打包命令之後, 文件可以轉成 文件 為什麼運行打包命令之後, 語法可以轉成 語法 "[外鏈圖片轉存失敗,源 ...
  • 幹了這麼多年的前端,之前面試的時候經常會遇到面試官提問:你是如何理解HTML的語義化的? 說實話,之前遇到這個問題的時候,都是從網上找參考答案,然後記下來,用自己的語言重新組織一下,就變成自己的理解了。 為什麼說要重學HTML5的語義化,是因為今年以來,公司安排了一項任務給我,讓我做一個自項目的官網 ...
  • 原文:Interview with a Pornhub Web Developer 譯者:neal1991 welcome to star my articles-translator, providing you advanced articles translation. Any suggest ...
  • 字元串方法幫助您處理字元串。 字元串方法和屬性 原始值,比如“Bill Gates”,無法擁有屬性和方法(因為它們不是對象)。 但是通過 JavaScript,方法和屬性也可用於原始值,因為在執行方法和屬性時 JavaScript 將原始值視為對象。 字元串方法和屬性 原始值,比如“Bill Gat ...
  • <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv ...
一周排行
    -Advertisement-
    Play Games
  • Dapr Outbox 是1.12中的功能。 本文只介紹Dapr Outbox 執行流程,Dapr Outbox基本用法請閱讀官方文檔 。本文中appID=order-processor,topic=orders 本文前提知識:熟悉Dapr狀態管理、Dapr發佈訂閱和Outbox 模式。 Outbo ...
  • 引言 在前幾章我們深度講解了單元測試和集成測試的基礎知識,這一章我們來講解一下代碼覆蓋率,代碼覆蓋率是單元測試運行的度量值,覆蓋率通常以百分比表示,用於衡量代碼被測試覆蓋的程度,幫助開發人員評估測試用例的質量和代碼的健壯性。常見的覆蓋率包括語句覆蓋率(Line Coverage)、分支覆蓋率(Bra ...
  • 前言 本文介紹瞭如何使用S7.NET庫實現對西門子PLC DB塊數據的讀寫,記錄了使用電腦模擬,模擬PLC,自至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1.Windows環境下鏈路層網路訪問的行業標準工具(WinPcap_4_1_3.exe)下載鏈接:http ...
  • 從依賴倒置原則(Dependency Inversion Principle, DIP)到控制反轉(Inversion of Control, IoC)再到依賴註入(Dependency Injection, DI)的演進過程,我們可以理解為一種逐步抽象和解耦的設計思想。這種思想在C#等面向對象的編 ...
  • 關於Python中的私有屬性和私有方法 Python對於類的成員沒有嚴格的訪問控制限制,這與其他面相對對象語言有區別。關於私有屬性和私有方法,有如下要點: 1、通常我們約定,兩個下劃線開頭的屬性是私有的(private)。其他為公共的(public); 2、類內部可以訪問私有屬性(方法); 3、類外 ...
  • C++ 訪問說明符 訪問說明符是 C++ 中控制類成員(屬性和方法)可訪問性的關鍵字。它們用於封裝類數據並保護其免受意外修改或濫用。 三種訪問說明符: public:允許從類外部的任何地方訪問成員。 private:僅允許在類內部訪問成員。 protected:允許在類內部及其派生類中訪問成員。 示 ...
  • 寫這個隨筆說一下C++的static_cast和dynamic_cast用在子類與父類的指針轉換時的一些事宜。首先,【static_cast,dynamic_cast】【父類指針,子類指針】,兩兩一組,共有4種組合:用 static_cast 父類轉子類、用 static_cast 子類轉父類、使用 ...
  • /******************************************************************************************************** * * * 設計雙向鏈表的介面 * * * * Copyright (c) 2023-2 ...
  • 相信接觸過spring做開發的小伙伴們一定使用過@ComponentScan註解 @ComponentScan("com.wangm.lifecycle") public class AppConfig { } @ComponentScan指定basePackage,將包下的類按照一定規則註冊成Be ...
  • 操作系統 :CentOS 7.6_x64 opensips版本: 2.4.9 python版本:2.7.5 python作為腳本語言,使用起來很方便,查了下opensips的文檔,支持使用python腳本寫邏輯代碼。今天整理下CentOS7環境下opensips2.4.9的python模塊筆記及使用 ...