zoukankan      html  css  js  c++  java
  • Java 学习笔记(一)

    1、要使用@MapperScan注解,需要在pom.xml中导入mybatis包:

    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>2.0.0</version>
    </dependency>

    2、 要使用@Mapper注解,需要在pom.xml中导入mybatis包:
    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.4.5</version>
    </dependency>

    3、mybatis的xml 与mapper注解 select,update等的比较。直接在代码中写注解,复杂的sql写起来费劲,而且需要重新部署,xml还是亦一样的 是配置型。

    4、Error creating bean with name 'loginService': Unsatisfied dependency expressed through field 'userDao'; 
    检查文件名,包名,有没有多写一个字符,少写一个字符,有没有大小写没区分。各个地方使用到的名称要一一对应的。
    也有可能某一个serviceImpl没有加@service注解,而这个service不一定是错误描述里的service.
    *mapper.xml里的方法有问题,有重复的id

    5、This application has no explicit mapping for /error, so you are seeing this as a fallback.
    如果status=404,表示要配置thymeleaf
    如果status=500,表示资源文件不存在,即html文件不存在。
    springboot 2 默认已经不用jsp了,而用thymeleaf了。ref: https://www.imooc.com/article/20304

    6、Java的getter setter规范:https://blog.csdn.net/zhangzeyuaaa/article/details/46649061 https://rongmayisheng.com/?p=1329 不按照规范来,就按没有属性处理。

    7、Error resolving template [fragments/header] https://blog.csdn.net/liyanlei5858/article/details/80183409

    在Springboot中,默认读取thymeleaf文件的路径是:src/main/resource/templates,静态文件为src/main/resource/static,这个默认值可以在配置文件中修改:spring.thymeleaf.prefix=classpath:/templates/

    所有在调用fragment时,是默认从thymeleaf的根路径开始设置的: 
    例如 
    <head th:replace="/include/header::head" > 
    从读取templates/include/header.html中 fragment=head的代码块

       8、jssessionid 出现在标题栏

       9、login界面加载不了css, F12进去可以看到css 文件的返回状态是302

        原因是添加过自定义的过滤器 

    HandlerInterceptor,在过滤器中设定了只有login 和error是直接放行,其他所有的请求都要检查session中用户的登录情况,未登录的所有请求都会redirect 到login.  但这里面没有排除资源文件的请求。所以对资源文件的请求也被转发了。这也就导致了第一次登录的login界面的css文件无法加载。解决办法就是判断下请求的类型
        /**
         * <p>
         * Determine if the request is about to be handled by a mapping configured
         * by <mvc:resources>
         * </p>
         *
         * @param handler
         *            - the handler to inspect
         * @return - true if this is a <mvc:resources> mapped request, false
         *         otherwise
         */
        private boolean isResourceHandler(Object handler)
        {
            return handler instanceof ResourceHttpRequestHandler;
        }
        @Override
        public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
    
            if (isResourceHandler(arg2))
                return true;
        }




     
     
  • 相关阅读:
    nginx限速 原理
    规则引擎 图形界面
    阿里巴巴 规则引擎
    martinfowler Data Guide big data bad things
    Nginx Request URI too large
    linux2.6.30.4内核移植(1)
    根文件系统
    Linux内核配置:定制配置选项
    Linux内核配置:Kconfig
    Linux内核配置:Makefile目标
  • 原文地址:https://www.cnblogs.com/crazyghostvon/p/Javalearn1.html
Copyright © 2011-2022 走看看