• ssm配置文件


    mybatis配置文件SqlMapConfig.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>
        <plugins>
            <plugin interceptor="com.github.pagehelper.PageInterceptor">
                <property name="helperDialect" value="mysql"></property>
            </plugin>
        </plugins>
    </configuration>

    spring配置文件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"
            xsi:schemaLocation="   
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
                http://www.springframework.org/schema/context
                http://www.springframework.org/schema/context/spring-context.xsd">  
        <!--
            使spring扫描包下的所有类,让标注spring注解的类生效 
            若扫描到有@Component @Controller@Service等这些注解的类,则把这些类注册为bean
        -->
        <context:component-scan base-package="edu.cn.service"/>
        <context:component-scan base-package="edu.cn.dao"/>
    
        <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
            <property name="url" value="jdbc:mysql://localhost:3306/smbms?characterEncoding=utf8"></property>
            <property name="username" value="root"></property>
            <property name="password" value="123"></property>
        </bean>
    
        <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="druidDataSource"></property>
            <property name="mapperLocations" value="classpath:mapper/*Mapper.xml"></property>
            <property name="configLocation" value="classpath:SqlMapConfig.xml"></property>
        </bean>
    
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="edu.cn.dao"></property>
        </bean>
    
    </beans>

    springmvc配置文件springmvc.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd">
            
        <context:component-scan base-package="edu.cn.controller"/>
        <mvc:annotation-driven/>
        <mvc:resources mapping="/statics/**" location="/statics/"/>
        <!-- 完成视图的对应 -->
        <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
            <property name="prefix" value="/WEB-INF/jsp/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
        
        <!--  全局异常处理 -->
        <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
            <property name="exceptionMappings">
                <props>
                    <prop key="java.lang.RuntimeException">login</prop>
                </props>
            </property>
        </bean>
    </beans>

    web.xml

    <!DOCTYPE web-app PUBLIC
     "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
     "http://java.sun.com/dtd/web-app_2_3.dtd" >
    
    <web-app>
      <display-name>Archetype Created Web Application</display-name>
    
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
      </context-param>
    
      <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>SMBMS_C09_04.root</param-value>
      </context-param>
    
      <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j.properties</param-value>
      </context-param>
    
      <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>
          org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <!--针对request-->
        <init-param>
          <param-name>encoding</param-name>
          <param-value>UTF-8</param-value>
        </init-param>
        <!--针对response-->
        <init-param>
          <param-name>forceEncoding</param-name>
          <param-value>true</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    
      <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
      </listener>
    
      <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>*.html</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
    
      <welcome-file-list>
        <welcome-file>/WEB-INF/jsp/login.jsp</welcome-file>
      </welcome-file-list>
      
    </web-app>
  • 相关阅读:
    【未完成】【oracle】add_months与add_days
    【java】[null]的问题
    PID控制算法研究
    matlab函数:residue和residuez的用法
    Windows入门基础:2.vs2013中Icon显示
    关于for()循环使用过程中遇到的问题(俄罗斯方块游戏中遇到的问题)
    Windows入门基础:1.关于CreateWindow()函数使用中遇到的问题
    error C4996: 'swprintf': swprintf has been changed to conform with the ISO C standard,set _CRT_NON_CONFORMING_SWPRINT
    QT5.3.2与VS2013 fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突_(解决方案)
    Java如何访问private变量
  • 原文地址:https://www.cnblogs.com/yanguobin/p/11517582.html
Copyright © 2020-2023  润新知