考试考点

2019-06-22  本文已影响0人  吴繁飞

一.springmvc是什么?好处是什么?工作流程?常用注解

1,springmvc是spring里面的一个模块,springMVC是一种web层mvc框架,用于替代servlet,
2,简化开发,使团队开发时候分工明确

1、 首先用户发送请求——>DispatcherServlet,前端控制器收到请求后自己不进行处理,而是委托给其他的解析器进行处理,作为统一访问点,进行全局的流程控制;

2、 DispatcherServlet——>HandlerMapping, HandlerMapping将会把请求映射为HandlerExecutionChain对象(包含一个Handler处理器(页面控制器)对象、多个HandlerInterceptor拦截器)对象,通过这种策略模式,很容易添加新的映射策略;

3、 DispatcherServlet——>HandlerAdapter,HandlerAdapter将会把处理器包装为适配器,从而支持多种类型的处理器,即适配器设计模式的应用,从而很容易支持很多类型的处理器;

4、 HandlerAdapter——>处理器功能处理方法的调用,HandlerAdapter将会根据适配的结果调用真正的处理器的功能处理方法,完成功能处理;并返回一个ModelAndView对象(包含模型数据、逻辑视图名);

5、 ModelAndView的逻辑视图名——> ViewResolver, ViewResolver将把逻辑视图名解析为具体的View,通过这种策略模式,很容易更换其他视图技术;

6、 View——>渲染,View会根据传进来的Model模型数据进行渲染,此处的Model实际是一个Map数据结构,因此很容易支持其他视图技术;

7、返回控制权给DispatcherServlet,由DispatcherServlet返回响应给用户,到此一个流程结束。
4,,,,
https://www.jianshu.com/p/853cd65bf697

二.spring
ioc 控制反转

    <bean id="Text" class="com.lianwei.entity.Text">
        <!--<property name="name" value="zje"></property>-->
        <!--<property name="age" value="24"></property>-->
    </bean>
//获取配置文件
 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//获取里面的ben
        Text text =(Text) context.getBean("Text");

aop 面向切面编程

@Aspect
@Component
public class Text1 {

    @Pointcut("execution(* com.lianwei.entity.Text.getAge())")
    private void pointCutMethod() {
    }
    @Before("pointCutMethod() ")
    public void doBefore(JoinPoint joinPoint) {
        System.out.println("@Before:开始添加");
    }



}

三 .mybatis
映射文件
rusultmap 返回映射结果集
点这里:https://www.jianshu.com/p/73807a6b7201

一对多
<resultMap id="ClazzMap" type="com.huhong.model.Clazz" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <collection property="students" column="id" javaType="ArrayList"
                ofType="com.huhong.model.Student"
                select="com.huhong.dao.StudentDao.selectStudentByClazzId"
                fetchType="lazy">
      <id column="id" property="id"/>
      <result column="name" property="name"/>
      <result column="sex" property="sex"/>
    </collection>
  </resultMap>
多对一
 <resultMap id="BaseResultMap" type="com.huhong.model.Student" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="VARCHAR" />
    <association property="clazz" javaType="com.huhong.model.Clazz">
       <id property="id" column="cid"/>
      <result property="name" column="cname"/>
    </association>
  </resultMap>




如果返回list集合就直接返回resultmap里面的id,如果想知到影响行数就不用返回

动态sql点这里:https://blog.csdn.net/m0_38054145/article/details/81906343

  #{}:占位符号,好处防止sql注入
jdbcType;是放在#{}里面的用来定义数据类型  where user_id = #{user_id,jdbcType=INTEGER}
  ${}:sql拼接符号
mybatis里面的语法:https://blog.csdn.net/oYeYuanXinZhiZhu1/article/details/80937886
<select id="getStudentListChoose" parameterType="Student" resultMap="BaseResultMap">
    SELECT * from STUDENT WHERE 1=1
    <where>
        <choose>
            <when test="Name!=null and student!='' ">
                AND name LIKE CONCAT(CONCAT('%', #{student}),'%')
            </when>
            <when test="hobby!= null and hobby!= '' ">
                AND hobby = #{hobby}
            </when>
            <otherwise>
                AND AGE = 15
            </otherwise>
        </choose>
    </where>
</select>


四.log4j

log4j就是一个开源的日志管理工具, 可以很详细的记录log.
例如程序最后部署在服务器以后, 如果运行报错了, 你怎么解决呢,你知道哪里出问题了吗?
这个时候就可以用log4j来看日志了, 可以很清楚的查看, error信息 deubg info等等

五.遇到异常有哪些


六.ssmdemo1分页查询


forward
redirec

上一篇下一篇

猜你喜欢

热点阅读