• 商城


    商城简介

    网上商城类似于,京东商城,天猫商城,会员可以在商城中浏览商品,下订单,以及参加各种活动。

    管理员,运营可以在管理后台系统中管理商品,订单,会员等。

    客服可以在后台管理系统中处理用户的询问以及投诉

    分布式系统架构

    分布式架构:

    把系统按照模块拆分成多个子模块。

    把模块拆分,使用接口通信,降低模块之间的耦合度。

    把项目拆分成若干个子项目,不同的团队负责不同的子模块。

    增加功能只需要增加一个子项目,调用其它项目接口就行。

    可以灵活的进行分布式部署

    缺点

    系统之间交互需要使用远程通信,接口开发增加工作量。

    3.6  技术选型

    数据库:mysql

    Dao层:mybatis 德鲁伊(druid)

    缓存:redis

    搜索:solr

    service:spring

    web:springmvc,jstl,EasyUI,jsp,freemake

    图片服务器:FastDFS(分布式文件系统)

    反向代理服务器:nginx

    定时器:Quartz

    Web服务器:tomcat

    远程调用:zookeeper,dubbo

    工程管理:maven

    4   后台管理系统搭建

    工程分析

    网站一般分前台和后台,前台给用户看后台是给管理人员看。

    使用maven管理工具

    1、依赖管理

    2、项目构建

    后台创建一个独立的web项目,创建一个maven工程打包方式是war包

    ego-parent(父工程管理jar包的版本)

    ego-commons (把通用的工具类打包)

    ego-mananger(继承父工程 pom文件)

    <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">
        <parent>
            <artifactId>ego_parent</artifactId>
            <groupId>com.github.ego.parent</groupId>
            <version>0.0.1-SNAPSHOT</version>
            <relativePath>../ego_parent/pom.xml</relativePath>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.github.ego.manager</groupId>
      <artifactId>ego_manager</artifactId>
        <packaging>pom</packaging>
    
      <name>ego_manager</name>
      <url>http://maven.apache.org</url>
        <modules>
            <module>../ego_manager_domain</module>
            <module>../ego_manager_mapper</module>
            <module>../ego_manager_service</module>
            <module>../ego_manager_web</module>
        </modules>
    
        <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
    
      <dependencies>
          <!--依赖于ego_commons-->
        <dependency>
            <groupId>com.github.ego.commons</groupId>
            <artifactId>ego_commons</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
      </dependencies>
        <build>
            <!-- 配置tomcat插件 -->
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <configuration>
                        <port>5050</port>
                        <path>/ego_manager</path>
                    </configuration>
    
                    <!--  <configuration>
                          <url>http://192.168.239.10:8080/manager/text</url>
                          <server>tomcat</server>
                          <path>/ego_manager</path>
                      </configuration>-->
                </plugin>
            </plugins>
        </build>
    </project>

    ego_manager_domain  (pom文件)

    <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">
        <parent>
            <artifactId>ego_manager</artifactId>
            <groupId>com.github.ego.manager</groupId>
            <version>0.0.1-SNAPSHOT</version>
            <relativePath>../ego_manager/pom.xml</relativePath>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.github.ego.manager</groupId>
      <artifactId>ego_manager_domain</artifactId>
        <packaging>jar</packaging>
    
      <name>ego_manager_domain</name>
      <url>http://maven.apache.org</url>
    
      <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
    
      <dependencies>
          <!--单元测试-->
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </project>

    domain

    
    
    package com.bjsxt.domain;

    //商品的domain类
    public class Product extends BaseDomain{

    private Integer flowerid ; //鲜花编号
    private String flowerisbn; //鲜花
    private String flowertype; //鲜花的象征
    private String flowername; //鲜花名字
    private String flowermaterial; //鲜花材料
    private String flowerpack; //鲜花包裹
    private String flowerdesc; //鲜花描述
    private String flowerimage; //鲜花图片
    private Double price; //鲜花价格
    private Double currentprice; //当前价格
    private String deliverarea ; //销售地区
    private String notetime; //笔记时间
    private Integer status; //状态码
    private Integer typeid; //类型编号


    public Integer getFlowerid() {
    return flowerid;
    }
    public void setFlowerid(Integer flowerid) {
    this.flowerid = flowerid;
    }
    public String getFlowerisbn() {
    return flowerisbn;
    }
    public void setFlowerisbn(String flowerisbn) {
    this.flowerisbn = flowerisbn;
    }
    public String getFlowertype() {
    return flowertype;
    }
    public void setFlowertype(String flowertype) {
    this.flowertype = flowertype;
    }
    public String getFlowername() {
    return flowername;
    }
    public void setFlowername(String flowername) {
    this.flowername = flowername;
    }
    public String getFlowermaterial() {
    return flowermaterial;
    }
    public void setFlowermaterial(String flowermaterial) {
    this.flowermaterial = flowermaterial;
    }
    public String getFlowerpack() {
    return flowerpack;
    }
    public void setFlowerpack(String flowerpack) {
    this.flowerpack = flowerpack;
    }
    public String getFlowerdesc() {
    return flowerdesc;
    }
    public void setFlowerdesc(String flowerdesc) {
    this.flowerdesc = flowerdesc;
    }
    public String getFlowerimage() {
    return flowerimage;
    }
    public void setFlowerimage(String flowerimage) {
    this.flowerimage = flowerimage;
    }
    public Double getPrice() {
    return price;
    }
    public void setPrice(Double price) {
    this.price = price;
    }
    public Double getCurrentprice() {
    return currentprice;
    }
    public void setCurrentprice(Double currentprice) {
    this.currentprice = currentprice;
    }
    public String getDeliverarea() {
    return deliverarea;
    }
    public void setDeliverarea(String deliverarea) {
    this.deliverarea = deliverarea;
    }
    public String getNotetime() {
    return notetime;
    }
    public void setNotetime(String notetime) {
    this.notetime = notetime;
    }
    public Integer getStatus() {
    return status;
    }
    public void setStatus(Integer status) {
    this.status = status;
    }
    public Integer getTypeid() {
    return typeid;
    }
    public void setTypeid(Integer typeid) {
    this.typeid = typeid;
    }



    }
     

    BaseDomain

    package com.bjsxt.domain;
    
    public class BaseDomain {
         private Integer page; //当前页
         private Integer rows; //每页的数量
        public Integer getPage() {
            return page;
        }
        public void setPage(Integer page) {
            this.page = page;
        }
        public Integer getRows() {
            return rows;
        }
        public void setRows(Integer rows) {
            this.rows = rows;
        }
         
         
    }

    ego_manager_mapper  (pom文件)

    <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">
    <parent>
    <artifactId>ego_manager</artifactId>
    <groupId>com.bjsxt.ego.manager</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../ego_manager/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.bjsxt.ego.manager</groupId>
    <artifactId>ego_manager_mapper</artifactId>
    <packaging>jar</packaging>

    <name>ego_manager_mapper</name>
    <url>http://maven.apache.org</url>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

    <!--单元测试-->
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    </dependency>

    <!-- 依赖ego_manager_domain -->
    <dependency>
    <groupId>com.bjsxt.ego.manager</groupId>
    <artifactId>ego_manager_domain</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <!-- Mybatis -->
    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    </dependency>
    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    </dependency>
    <dependency>
    <groupId>com.github.miemiedev</groupId>
    <artifactId>mybatis-paginator</artifactId>
    </dependency>
    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    </dependency>
    <!-- MySql -->
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <!-- 连接池 -->
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    </dependency>

    </dependencies>

    <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
    <build>
    <resources>
    <resource>
    <directory>src/main/java</directory>
    <includes>
    <include>**/*.properties</include>
    <include>**/*.xml</include>
    </includes>
    <filtering>false</filtering>
    </resource>
    </resources>
    </build>


    </project>

    mapper文件 (productMapper.java)

    package com.bjsxt.mapper;
    
    import com.bjsxt.domain.Product;
    
    import java.util.List;
    
    public interface ProductMapper {
        
        //向数据库中添加鲜花
        void addProduct(Product product);
        
        //查询所有
        List<Product> loadProduct();
    }

    mapper配置文件  (productMapper.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.bjsxt.mapper.ProductMapper">
             <insert id="addProduct" parameterType="com.bjsxt.domain.Product">
                 insert
                    into flower
                     values
                     (null,
                     #{flowerisbn},
                     #{flowertype},
                     #{flowername},
                     #{flowermaterial},
                     #{flowerpack},
                     #{flowerdesc},
                     #{flowerimage},
                     #{price},
                     #{currentprice},
                     #{deliverarea},
                     #{notetime},
                     #{status},
                     #{typeid})
             </insert>
             
             <!-- 查询所有商品信息 -->
             <select id="loadProduct" resultType="com.bjsxt.domain.Product">
                  select
                  *
                  from flower
             </select>
          
         </mapper>
         

    ego-manager-service

    package com.bjsxt.service;
    
    import com.bjsxt.vo.ProductVo;
    import com.bjsxt.vo.DataGridModel;
    
    public interface ProductService {
       
        //添加鲜花
        void addProduct(ProductVo pvo);
        
        //查询所有的鲜花产品
        DataGridModel<ProductVo> loadProductService(ProductVo pvo);
    }
    package com.bjsxt.service.impl;
    
    import com.bjsxt.domain.Product;
    import com.bjsxt.mapper.ProductMapper;
    import com.bjsxt.service.ProductService;
    import com.bjsxt.utils.DateUtils;
    import com.bjsxt.vo.DataGridModel;
    import com.bjsxt.vo.ProductVo;
    import com.github.pagehelper.Page;
    import com.github.pagehelper.PageHelper;
    import org.springframework.beans.BeanUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import java.util.List;
    
    @Service //将产品纳入到spring容器中
    public class ProductServiceImpl  implements ProductService {
    
        //注入代理对象
        @Autowired
        private ProductMapper productMapper;
        
        @Override
        public void addProduct(ProductVo pvo) {
            //设置日期
            pvo.setNotetime(DateUtils.getFormateDate());
            //设置正常消费
            pvo.setStatus(1);
            //添加商品信息
            productMapper.addProduct(pvo);
        }
    
        
        @Override
        public DataGridModel<ProductVo> loadProductService(ProductVo pvo) {
            
            //创建dataGridModel对象
            DataGridModel<ProductVo> dgm = new DataGridModel<ProductVo>();
            
            //分页对象
             Page page = PageHelper.startPage(pvo.getPage(), pvo.getRows());
            
            //创建product对象
            List<Product> loadProduct = productMapper.loadProduct();
            
            //遍历
            for (Product product : loadProduct) {
                
                //创建productVo对象
                ProductVo productvo = new ProductVo();
                BeanUtils.copyProperties(product, productvo);
                dgm.getRows().add(productvo);
            }
    
            //设置总数
            dgm.setTotal(page.getTotal());
            return dgm;
        }
    
    }

    vo对象DataGridModel

    package com.bjsxt.vo;
    
    import java.util.ArrayList;
    import java.util.List;
    
    //datagrid:完成数据的列表的分页显示
    public class DataGridModel<T> {
           
        //需要响应的总行 
          private Long total;
          private List<T> rows = new ArrayList<T>();
          
        public Long getTotal() {
            return total;
        }
        public void setTotal(Long total) {
            this.total = total;
        }
        public List<T> getRows() {
            return rows;
        }
        public void setRows(List<T> rows) {
            this.rows = rows;
        }
          
          
    }

    productVo对象

    package com.bjsxt.vo;
    
    import com.bjsxt.domain.Product;
    
    public class ProductVo extends Product{
    
    }

    ego-manager-web(pom文件)对象

    <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/maven-v4_0_0.xsd">
        <parent>
            <artifactId>ego_manager</artifactId>
            <groupId>com.bjsxt.ego.manager</groupId>
            <version>0.0.1-SNAPSHOT</version>
            <relativePath>../ego_manager/pom.xml</relativePath>
        </parent>
        <modelVersion>4.0.0</modelVersion>
      <groupId>com.bjsxt.ego.manager</groupId>
      <artifactId>ego_manager_web</artifactId>
      <packaging>war</packaging>
        <name>ego_manager_web Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
          <!-- 依赖ego_manager_service -->
          <dependency>
              <groupId>com.bjsxt.ego.manager</groupId>
              <artifactId>ego_manager_service</artifactId>
              <version>0.0.1-SNAPSHOT</version>
          </dependency>
          <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>spring-webmvc</artifactId>
          </dependency>
    
          <dependency>
              <groupId>javax.servlet</groupId>
              <artifactId>servlet-api</artifactId>
              <scope>provided</scope>
          </dependency>
          <dependency>
              <groupId>javax.servlet</groupId>
              <artifactId>jsp-api</artifactId>
              <scope>provided</scope>
          </dependency>
          <dependency>
              <groupId>jstl</groupId>
              <artifactId>jstl</artifactId>
          </dependency>
    
          <dependency>
              <groupId>commons-fileupload</groupId>
              <artifactId>commons-fileupload</artifactId>
          </dependency>
    
      </dependencies>
      <build>
          <finalName>ego_manager_web</finalName>
      </build>
    </project>

    productController

    package com.bjsxt.controller;

    import com.bjsxt.service.ProductService;
    import com.bjsxt.utils.FtpUtils;
    import com.bjsxt.vo.DataGridModel;
    import com.bjsxt.vo.ProductVo;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.multipart.MultipartFile;

    import java.io.IOException;
    import java.io.InputStream;
    import java.util.UUID;

    @Controller
    public class ProductController {

    //注入service对象
    @Autowired
    private ProductService productService;

    @RequestMapping("/jumping")
    public String jumping(){
    return "index.jsp";
    }

    @RequestMapping("/addProductUI")
    public String loadProduct(){
    return "addProduct";

    }

    //跳转产品的ui界面
    @RequestMapping("/loadProductUI")
    public String loadProductUI(){
    return "productList";
    }

    //处理商品的添加
    @RequestMapping("/addProduct")
    public String addProduct(ProductVo pvo , MultipartFile mf){
    try {
    //图片路径
    String newname = UUID.randomUUID().toString().replace("-", "");
    String oldname = mf.getOriginalFilename();
    String ext = oldname.substring(oldname.lastIndexOf("."));
    newname = newname +ext;

    //将上传文件访问输入流对象
    InputStream is = mf.getInputStream();
    FtpUtils.ftpFileUpload("192.168.239.113", 21, "ftpuser", "ftpuser", "/home/ftpuser/images", newname, is);

    String flowerimage = "http://www.wugui.com/"+newname;
    //保存图片
    pvo.setFlowerimage(flowerimage);

    //添加产品
    productService.addProduct(pvo);


    } catch (IOException e) {
    e.printStackTrace();
    }
    return "productList";
    }

    //查询所有产品信息
    @RequestMapping("/loadProductList")
    @ResponseBody
    public DataGridModel<ProductVo> loadProductList(ProductVo pvo){
    return productService.loadProductService(pvo);
    }



    }

    ckeditController

    package com.bjsxt.controller;
    
    import com.bjsxt.utils.FtpUtils;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.multipart.MultipartFile;
    
    import java.io.InputStream;
    import java.util.UUID;
    /**
     * Created by asus on 2017/12/8.
     */
    @Controller //将ckedit纳入到spring容器中
    public class CkeditController {
    
        //处理ckedit文件上传请求
        @RequestMapping("/ckeditUpload")
        @ResponseBody
        public String ckeditUpload(MultipartFile upload , String CKEditorFuncNum){
    
            try {
                //图片路径
                String newname = UUID.randomUUID().toString().replace("-", "");
                String oldname = upload.getOriginalFilename();
                String ext = oldname.substring(oldname.lastIndexOf("."));
                newname = newname +ext;
    
                //将文件上传访问输入流对象
                InputStream is = upload.getInputStream();
    
                FtpUtils.ftpFileUpload("192.168.239.113", 21, "ftpuser", "ftpuser", "/home/ftpuser/images", newname, is);
    
                String flowerimage = "http://www.wugui.com/"+newname;
    
                //创建stringbuffer
                StringBuffer sbf = new StringBuffer();
                sbf.append("<script type="text/javascript">");
                sbf.append("window.parent.CKEDITOR.tools.callFunction("+ CKEditorFuncNum + ",'" +flowerimage+ "','')");
                sbf.append("</script>");
                System.out.println(sbf.toString());
                return sbf.toString();
    
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
            return null;
        }
    
    }

    applicationMapper.xml文件

    <beans xmlns="http://www.springframework.org/schema/beans"
    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.xsd">


    <!--实例化数据库连接池-->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <!--<property name="url" value="jdbc:mysql://localhost:3306/ego"></property>-->
    <property name="url" value="jdbc:mysql://192.168.239.10:3306/ego"></property>
    <property name="username" value="root"></property>
    <property name="password" value="root"></property>
    </bean>

    <!--创建sqlSessionFactory工厂 实例化sqlSessionFactory spring整合mybatis 不需要映射文件-->
    <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!--给sqlSessionFactory 注入dataSource -->
    <property name="dataSource" ref="dataSource"></property>

    <!-- 配置分页插件 -->
    <property name="plugins">
    <list>
    <bean class="com.github.pagehelper.PageHelper">
    <property name="properties">
    <props>
    <prop key="dialect">mysql</prop>
    <prop key="reasonable">true</prop>
    </props>
    </property>
    </bean>
    </list>
    </property>

    </bean>

    <!-- 通过mapperScaner扫描,产生mapper的代理对象 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- 指定要扫描的包 -->
    <property name="basePackage" value="com.bjsxt.mapper"></property>
    <!-- 注入sqlSessionFactory对象 -->
    <property name="sqlSessionFactoryBeanName" value="sessionFactory"></property>
    </bean>
    </beans>

    applicationService.xml文件

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

    <!-- 自定义扫描 -->
    <context:component-scan base-package="com.bjsxt.service"></context:component-scan>

    <!-- 配置事物管理器 实例化事物管理器对象-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
    </bean>

    <!-- 配置开启事物的操作 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <!-- 指定在连接方法上面应用事物的属性 -->
    <tx:method name="add*" propagation="REQUIRED" read-only="false"/>
    <tx:method name="update*" propagation="REQUIRED" read-only="false"/>
    <tx:method name="delete*" propagation="REQUIRED" read-only="false"/>
    <tx:method name="save*" propagation="REQUIRED" read-only="false"/>
    <tx:method name="load*" propagation="REQUIRED"/>
    <tx:method name="get*" propagation="REQUIRED"/>
    <!-- 对于其他方法使用默认的事物管理器 -->
    <tx:method name="*"/>

    </tx:attributes>
    </tx:advice>

    <!-- 事物的aop配置 -->
    <aop:config>
    <!--切点 advice-ref 切面 pointcut-ref-->
    <aop:pointcut expression="execution(* com.bjsxt.service.impl.*.*(..))" id="pc"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/>
    </aop:config>


    </beans>

    springmvc.xml文件

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    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.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- 开启主键扫描 -->
    <context:component-scan base-package="com.bjsxt.controller"/>

    <!-- springmvc的注解驱动 -->
    <mvc:annotation-driven/>

    <!-- 配置视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/" />
    <property name="suffix" value=".jsp" />
    </bean>

    <!-- 文件上传配置文件 -->
    <bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="defaultEncoding" value="UTF-8"></property>
    <property name="maxUploadSize" value="1024000000"></property>
    </bean>

    </beans>

    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" id="WebApp_ID" version="2.5">
      <display-name>ego</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    
      <!-- 加载spring的配置文件 -->
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:application*.xml</param-value>
      </context-param>
    
    
      <!-- 配置监听器 -->
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    
      <!-- 处理springmvc的中文乱码 -->
      <filter>
        <filter-name>charset</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>charset</filter-name>
        <url-pattern>*.action</url-pattern>
      </filter-mapping>
    
      <!-- 配置springmvc的核心控制器 -->
      <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    
        <!-- 初始化参数 -->
        <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>classpath*:springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.action</url-pattern>
      </servlet-mapping>
    
    </web-app>
  • 相关阅读:
    CRC在线计算器
    freemodbus-v1.5.0 源码分析
    图及其实现
    最短路径
    交换排序-------快速排序
    FreeRTOS--删除任务
    Install OE and BitBake
    高端编程之DOM
    timeout使用实例
    使用JS提交表单
  • 原文地址:https://www.cnblogs.com/jacksonxiao/p/8473818.html
Copyright © 2020-2023  润新知