• Springmvc===整合问题总结


    1. 过滤字符编码 org.spring

     <filter>
            <filter-name>characterEncoding</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>utf8</param-value>       ///utf8 格式字符串
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>characterEncoding</filter-name>
            <url-pattern>/*</url-pattern>               //
        </filter-mapping>
    

    2.context:property-placeholder  location=classpath:*.properties  

    3.同一个项目的所有spring配置文件xml   Facets 在同一目录里

    4.要启动数据库 

    5.mabatis configurationlocation   value="classpath:*.xml"

    6.Idea webmvc 项目要将jar包导入输出Artifacets===》output 里

    7.context:annotation-config   启用mvc自动装配注解, context:component-scan  base-package="com..."     还有个什么自动代理来着? aop? 

    8.空指针,spring bean 使用要装配autowired

    7.Spring中存在大量设计模式:都有相应的后缀提示:

    如adpater  适配器模式:controllerhandlerapadter   

    configer 配置:characterencodingconfiger    webmvcconfiger   MapperScanconfiger

    builder 建造者模式: sqlsessionfactory().builder() builder设计模式 分解建造模块,每个模块都是一个建造对象,可以无序组装建造模块,组成需要的建造对象。

    factory 工程模式:是对同一类对象的建造,所有模式都和接口实现有关,抽象类增加方法,  appliactioncontext.getbean(..)   Class.newInstance(_)   Proxy.newInstance()创建代理对象,可以创建任意类型的代理对象, Sqlsession.getConnection(...)   calendar.getInstance()  抽象类实现创建日期对象。

    接口对象默认实现,可在接口中调用其他方法。

    if语句 并列式  和if  else if   else    的时间复杂度不一样,一个是每一个if都执行,一个是if判断满足条件就不会执行其他的else 了

    8. controller 中方法的返回值 视图,跳转网址  返回值   地址栏的地址变化

    9.  tx:advice 对应XML配置文件头引用的链接,一定看好,引用的时候引用的哪个,tx:adivce 提示有两个 内容还一样,要选不是cache的哪个,不然虽然一样,但是还是不会成功

    判断是否引对,可以看是不是灰色的不是灰色的是绿色的了就成功了。

    通配符的匹配很全面, 但无法找到元素 'tx:advice' 的声明

    <?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:tx="http://www.springframework.org/schema/tx"
           xmlns:aop="http://www.springframework.org/schema/aop"
           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
             https://www.springframework.org/schema/aop/spring-aop.xsd">

     10.servlet 配置,路径解析处理handler  conroller控制器适配处理   视图解析viewresolver     注解 扫描   放行资源   mvc context   

          数据库配置 mybaits  源  工厂 属性   自动创建dao的代理对象mapperscanhandler            服务层接口注册 

    事务管理有spring统一,基于aop 对method方法的增强,原理是动态代理Proxy和CGLIB  对应接口 和方法。 advice  pre  before  after around  pointcut execution   ****  aspect包  (/*  /**)

    tx标签     (mvc标签 注解)  bean的DI  D创建 方式   I 方式:spring去分配使用。

    SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@63787180] was not registered for synchronization because synchronization is not active。

    JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@4f1bfe23 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@e19bb76]] will not be managed by Spring。

    springmvc+c3p0+mybatis-spring  不配置事务管理,会提示不是异步,异步没激活,JDBC连接没有被spring管理,原因:spring声明式事务对调用的数据库方法。。拦截管理。

      数据库查询 DDL DML DQL  DCL    

       handlerInterceptor 接口拦截器 原理aop 的 false  拦截 不执行其他拦截器  true 不拦截 继续下面的拦截器  所以拦截器有顺序(SpringMVC 专有)需要在spring中配置注册。

    <mvc:interceptors>
    <mvc:interceptor>
    <mvc:mapping path=""/>
    <
    </mvc:interceptor>
    </mvc:interceptors>
    接口点 advice:

    Spring AOP 提供了 Advice 接口多个子接口来支持增强。如下所示:

    接口 MethodBeforeAdvice:在目标方法调用之前调用的Advice;

    接口 AfterReturningAdvice:在目标方法调用并返回之后调用的Advice;

    接口 MethodInterceptor:在目标方法的整个执行前后有效,并且有能力控制目标方法的执行;

    接口 ThrowsAdvice:在目标方法抛出异常时调用的Advice;

  • 相关阅读:
    [Codeforces 1245D] Shichikuji and Power Grid (最小生成树)
    [BZOJ 1535] [Luogu 3426]SZA-Template (KMP+fail树+双向链表)
    [BZOJ1009] [HNOI2008] GT考试(KMP+dp+矩阵快速幂)
    [Codeforces 1246B] Power Products (STL+分解质因数)
    [BZOJ 3992] [SDOI 2015] 序列统计(DP+原根+NTT)
    [BZOJ5306] [HAOI2018]染色(容斥原理+NTT)
    [Codeforces 1239D]Catowise City(2-SAT)
    [BZOJ 3527] [ZJOI2014]力(FFT)
    [BZOJ 3456]城市规划(cdq分治+FFT)
    【2-SAT(最小字典序/暴力染色)】HDU1814-Peaceful Commission
  • 原文地址:https://www.cnblogs.com/chencn/p/12354752.html
Copyright © 2020-2023  润新知