Java学习

1 Java基础

1.1    基本类型,运算符,表达式,循环语句

1.2 继承,封装,多态,接口,抽象类,匿名函数

1.3 常用工具

1.4 cmd下运行和环境搭建流程—jdk—eclipse—tomcat

1.5 数组,异常,集合

1.6 i/o文件读写

1.7 简单设计模式

A:

B:

C:

2 J2EE

2.1 8个系统变量–servlet-jstl

2.2 springmvc+mybatis

3 spring

3.1 AOP

3.1.1 使用注解AOP原理

面向切面编程,把散落在程序中的公共部分提取出来,做成切面类,这样的好处在于,代码的可重用,一旦涉及到该功能的需求发生变化,只要修改该代码就行,否则,你要到处修改,如果只要修改1、2处那还可以接受,万一有1000处呢。
AOP底层的东西就是JDK动态代理和CGLIB代理,说白了就是增强类的功能。
最常用的AOP应用在数据库连接以及事务处理上

3.1.2 注解使用AOP 方法

A: <aop:aspectj-autoproxyproxy-target-class="true"/>
B:@Aspect
@Component
public  classLogAdvice {
   privatestaticLogger log= LoggerFactory.getLogger(LogAdvice.class);
   
/**
     * service请求前日志
     * @param JoinPoint joinPoint 
     */
@Before("execution (*www.*.*(..))")
   publicvoidlogBeforeServiceImpl(JoinPoint joinPoint) {
        if (CommonUtil.isNotNull(joinPoint.getArgs())
length
            log.debug("********BeforeServiceClass="
                +joinPoint.getStaticPart().getSignature().toString());
            for (Object arg : joinPoint.getArgs()) {
                if (CommonUtil.isNotNull(arg)) {
                    log.debug("********parameter="
                }
            }
        }
   }
   
/**
     * service返回后日志
     * @param joinPoint
     * @param retVal 
     */
@AfterReturning(value=  "execution (* wqwqwqwq.*.*(..))", argNames = "retVal", returning = "retVal")
   publicvoidAfter(JoinPoint joinPoint, Object retVal) {
        log.debug("********AfterServiceClass="
            +joinPoint.getStaticPart().getSignature().toString());
        if (CommonUtil.isNotNull(retVal) && retVal instanceof RestResponse) {
            RestResponse resVal =(RestResponse)retVal;
            logDebug(resVal);
            if (resVal.getResponseCode() != 0)
                logError(joinPoint, resVal);
        }
        else  if (CommonUtil.isNotNull(retVal)){
            log.debug("********data="
        }
    }

3.2 拦截器

3.2.1 工作原理

 

3.2.2 使用步骤

a:

<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/tt/index"/>
<mvc:mapping path="/aa/job"/>
<mvc:mapping path="/ww/ss"/>
<mvc:mapping path="/jj/jobs "/>
<bean class="com.newegg.frontservice.web.interceptor.LoginHandlerInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
B: 写HandlerInterceptorAdapter具体实现类
 
 
1.  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)    
2.          throws Exception {    
3.          return true;    
4.  
5.      public void postHandle(    
6.  
7.              throws Exception {    
8.  
9.      public void afterCompletion(    
10. 
11.             throws Exception {    
12.


3.3 IOC 依赖注入

3.4 静态资源不作为请求

<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/scripts/**" location="/scripts/" />

3.5 读取静态文件

<bean class="abcsss.PropertiesUtil">
<property name="locations">
<list>
<value>classpath:ddd.properties</value>
<value>classpath:eee.properties</value>
</list>
</property>
</bean>

此时可以用@Value来读取譬如operties文件里的key value值

3.6 使用注解

开启注解功能

<context:component-scan base-package="abc.*"/>

3.7 事务和数据源配置