• springmvc企业级开发实战


    一、用eclipse插件搭建项目

    二、pom文件

      1  1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      2   2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      3   3     <modelVersion>4.0.0</modelVersion>
      4   4     <groupId>com</groupId>
      5   5     <artifactId>ssmm</artifactId>
      6   6     <packaging>war</packaging>
      7   7     <version>0.0.1-SNAPSHOT</version>
      8   8     <name>ssmm Maven Webapp</name>
      9   9     <url>http://maven.apache.org</url>
     10  10     <properties>
     11  11         <spring.version>4.0.4.RELEASE</spring.version>
     12  12     </properties>
     13  13     <dependencies>
     14  14          <dependency>
     15  15             <groupId>org.springframework</groupId>
     16  16             <artifactId>spring-core</artifactId>
     17  17             <version>${spring.version}</version>
     18  18         </dependency>
     19  19         <dependency>
     20  20             <groupId>org.springframework</groupId>
     21  21             <artifactId>spring-webmvc</artifactId>
     22  22             <version>${spring.version}</version>
     23  23         </dependency>
     24  24         <dependency>
     25  25             <groupId>org.springframework</groupId>
     26  26             <artifactId>spring-context</artifactId>
     27  27             <version>${spring.version}</version>
     28  28         </dependency>
     29  29         <dependency>
     30  30             <groupId>org.springframework</groupId>
     31  31             <artifactId>spring-context-support</artifactId>
     32  32             <version>${spring.version}</version>
     33  33         </dependency>
     34  34         <dependency>
     35  35             <groupId>org.springframework</groupId>
     36  36             <artifactId>spring-aop</artifactId>
     37  37             <version>${spring.version}</version>
     38  38         </dependency>
     39  39         <dependency>
     40  40             <groupId>org.springframework</groupId>
     41  41             <artifactId>spring-aspects</artifactId>
     42  42             <version>${spring.version}</version>
     43  43         </dependency>
     44  44         <dependency>
     45  45             <groupId>org.springframework</groupId>
     46  46             <artifactId>spring-tx</artifactId>
     47  47             <version>${spring.version}</version>
     48  48         </dependency>
     49  49      <dependency>
     50  50             <groupId>org.springframework</groupId>
     51  51             <artifactId>spring-test</artifactId>
     52  52             <version>${spring.version}</version>
     53  53             <scope>test</scope>
     54  54         </dependency>
     55  55         <dependency>
     56  56             <groupId>org.springframework</groupId>
     57  57             <artifactId>spring-jdbc</artifactId>
     58  58             <version>${spring.version}</version>
     59  59         </dependency>
     60  60         <dependency>
     61  61             <groupId>org.springframework</groupId>
     62  62             <artifactId>spring-web</artifactId>
     63  63             <version>${spring.version}</version>
     64  64         </dependency>
     65  65          <!-- json -->
     66  66         <dependency>
     67  67             <groupId>com.alibaba</groupId>
     68  68             <artifactId>fastjson</artifactId>
     69  69             <version>1.1.39</version>
     70  70         </dependency>
     71  71          <!-- servlet -->
     72  72         <dependency>
     73  73             <groupId>javax.servlet</groupId>
     74  74             <artifactId>servlet-api</artifactId>
     75  75             <version>2.5</version>
     76  76             <scope>provided</scope>
     77  77         </dependency>
     78  78          <!-- 这个是使用velocity的必备包 -->
     79  79         <dependency>
     80  80             <groupId>org.springframework</groupId>
     81  81             <artifactId>spring-context-support</artifactId>
     82  82             <version>3.2.6.RELEASE</version>
     83  83             <scope>compile</scope>
     84  84         </dependency>
     85  85         <!-- mysql -->
     86  86         <dependency>
     87  87             <groupId>mysql</groupId>
     88  88             <artifactId>mysql-connector-java</artifactId>
     89  89             <version>5.1.27</version>
     90  90             <scope>runtime</scope>
     91  91         </dependency>
     92  92         <!-- 数据源 -->
     93  93         <dependency>
     94  94             <groupId>org.apache.tomcat</groupId>
     95  95             <artifactId>tomcat-jdbc</artifactId>
     96  96             <version>7.0.47</version>
     97  97         </dependency>
     98  98         <!-- mybatis -->
     99  99         <dependency>
    100 100             <groupId>org.mybatis</groupId>
    101 101             <artifactId>mybatis</artifactId>
    102 102             <version>3.1.1</version>
    103 103         </dependency>
    104 104         <dependency>
    105 105             <groupId>org.mybatis</groupId>
    106 106             <artifactId>mybatis-spring</artifactId>
    107 107             <version>1.1.1</version>
    108 108         </dependency>
    109 109         <!-- velocity -->
    110 110         <dependency>
    111 111             <groupId>org.apache.velocity</groupId>
    112 112             <artifactId>velocity</artifactId>
    113 113             <version>1.5</version>
    114 114         </dependency>
    115 115         <dependency>
    116 116             <groupId>velocity-tools</groupId>
    117 117             <artifactId>velocity-tools-generic</artifactId>
    118 118             <version>1.2</version>
    119 119         </dependency>
    120 120     </dependencies>
    121 121     <build>
    122 122         <finalName>ssmm</finalName>
    123 123     </build>
    124 124 </project>
    pom.xml

    三、web.xml

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
     3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     5 
     6     <servlet>
     7         <servlet-name>dispatcherServlet</servlet-name>
     8         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     9         <init-param>
    10             <param-name>contextConfigLocation</param-name>
    11             <param-value>classpath*:spring*.xml</param-value>
    12         </init-param>
    13         <load-on-startup>1</load-on-startup>
    14     </servlet>
    15     <servlet-mapping>
    16         <servlet-name>dispatcherServlet</servlet-name>
    17         <url-pattern>/</url-pattern>
    18     </servlet-mapping>
    19 
    20     <filter>
    21         <filter-name>encodingFilter</filter-name>
    22         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    23         <init-param>
    24             <param-name>encoding</param-name>
    25             <param-value>UTF-8</param-value>
    26         </init-param>
    27         <init-param>
    28             <param-name>forceEncoding</param-name>
    29             <param-value>true</param-value>
    30         </init-param>
    31     </filter>
    32     <filter-mapping>
    33         <filter-name>encodingFilter</filter-name>
    34         <url-pattern>/*</url-pattern>
    35     </filter-mapping>
    36 
    37     <welcome-file-list>
    38         <welcome-file>/index.jsp</welcome-file>
    39     </welcome-file-list>
    40 </web-app>
    web.xml
  • 相关阅读:
    对Java课程的感想
    OO第二阶段总结
    OO第一作业周期(前四周)总结
    实验7 流类库和输入输出
    实验6 类的继承和多态
    实验5 类和对象3
    实验4 类与对象2
    实验3 类和对象
    实验2
    实验1
  • 原文地址:https://www.cnblogs.com/javaweb2/p/6225767.html
Copyright © 2020-2023  润新知