12月备忘录

1、bean的创建
在这里插入图片描述

2、热更新,更新代码之后按Ctrl+F9。
在这里插入图片描述

3、StringUtils类中isEmpty与isBlank的区别
org.apache.commons.lang.StringUtils类提供了String的常用操作,最为常用的判空有如下两种isEmpty(String str)和isBlank(String str)。

StringUtils.isEmpty(String str) 判断某字符串是否为空,为空的标准是 str==null 或 str.length()==0

System.out.println(StringUtils.isEmpty(null));        //true
System.out.println(StringUtils.isEmpty(""));          //true
System.out.println(StringUtils.isEmpty("   "));       //false
System.out.println(StringUtils.isEmpty("dd"));        //false

StringUtils.isBlank(String str) 判断某字符串是否为空或长度为0或由空白符(whitespace) 构成

System.out.println(StringUtils.isBlank(null));        //true
System.out.println(StringUtils.isBlank(""));          //true
System.out.println(StringUtils.isBlank("   "));       //true
System.out.println(StringUtils.isBlank("dd"));        //false 

4、拦截器方法调用图以源码
在这里插入图片描述

/**
	 * Apply preHandle methods of registered interceptors.
	 * @return {@code true} if the execution chain should proceed with the
	 * next interceptor or the handler itself. Else, DispatcherServlet assumes
	 * that this interceptor has already dealt with the response itself.
	 * 应用已注册拦截器的preHandle方法。@如果执行链应继续处理下一个侦听器或处理程序本身,则返回{@code true}。否则,DispatcherServlet假定此拦截器本身已经处理了响应。
	 */
	boolean applyPreHandle(HttpServletRequest request, HttpServletResponse response) throws Exception {
		for (int i = 0; i < this.interceptorList.size(); i++) {
			HandlerInterceptor interceptor = this.interceptorList.get(i);
			if (!interceptor.preHandle(request, response, this.handler)) {
				triggerAfterCompletion(request, response, null);
				return false;
			}
			this.interceptorIndex = i;
		}
		return true;
	}

	/**
	 * Apply postHandle methods of registered interceptors.
	 * 应用注册拦截器的postHandle方法。
	 */
	void applyPostHandle(HttpServletRequest request, HttpServletResponse response, @Nullable ModelAndView mv)
			throws Exception {

		for (int i = this.interceptorList.size() - 1; i >= 0; i--) {
			HandlerInterceptor interceptor = this.interceptorList.get(i);
			interceptor.postHandle(request, response, this.handler, mv);
		}
	}

	/**
	 * Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
	 * Will just invoke afterCompletion for all interceptors whose preHandle invocation
	 * has successfully completed and returned true.
	 * 在映射的HandlerInterceptor上触发AfterCompletion回调。将只为其preHandle调用已成功完成并返回true的所有拦截器调用AfterCompletion。
	 */
	void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response, @Nullable Exception ex) {
		for (int i = this.interceptorIndex; i >= 0; i--) {
			HandlerInterceptor interceptor = this.interceptorList.get(i);
			try {
				interceptor.afterCompletion(request, response, this.handler, ex);
			}
			catch (Throwable ex2) {
				logger.error("HandlerInterceptor.afterCompletion threw exception", ex2);
			}
		}
	}

5、按部门分组后显示工资为前三的员工信息

select * from emp as a where 3> (select count(*) from emp where deptno = a.deptno and sal < a.sal)  order by a.deptno ,a.sal

解析SQL:

3>… :目的是获取前三条数据,可以多次修改

emp where deptno = a.deptno :目的是确定分组字段

sal < a.sal :排序条件

3> (select count(*) from emp where deptno = a.deptno and sal < a.sal) :工资比我高的人不超过三个,也就是工资前三。

6、同一个tomcat下配置多个项目,在web.xml配置项目文件名与路径的映射。

<context-param>
     <param-name >UAPCAS</param-name >
     <param-value >/UAPCAS</param-value >
</context-param>

<!--如果报错就给主要的项目加上-->
<context-param>
	<param-name>webAppRootKey</param-name>
	<param-value> app.root </param-value>
</context-param>

“webapp.root”这个字符串可以随便写任何字符串。如果不配置默认值是”webapp.root”。

可以用System.getProperty(“webapp.root”)来动态获项目的运行路径。
一般返回结果例如:/usr/local/tomcat8/webapps/项目名
部署在同一容器中的Web项目,要配置不同的,不能重复,否则报类似下面的错误:

Web app root system property already set to different value: 'webapp.root' = [/home/user/tomcat/webapps/project1/] instead of [/home/user/tomcat/webapps/project2/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files! 

7、springboot的测试删除
在这里插入图片描述

8、js 判断字符串是否为空

//判断字符是否为空的方法
function isEmpty(obj){
    if(typeof obj == "undefined" || obj == null || obj == ""){
        return true;
    }

	if(obj == undefined || obj == null || obj == ""){
        return true;
    }

	else{
        return false;
    }
}

9、tomcat闪退显示jre环境问题
闪退的话,给startup.bat中添加PAUSE。
在这里插入图片描述
JRE问题的话是因为Tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat,只要在setclasspath.bat的开头声明环境变量(就可以了,原因是后来较新版本安装完不会自动登记环境变量JAVA_HOME,JRE_HOME。
给setclasspath.bat的开头添加红色标记部分,如下:

rem ---------------------------------------------------------------------------
rem Set CLASSPATH and Java options
rem
rem $Id: setclasspath.bat 505241 2007-02-09 10:22:58Z jfclere $
rem ---------------------------------------------------------------------------

//添加这两行
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20
set JRE_HOME=C:\Program Files\Java\jre6


rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo At least one of these environment variable is needed to run this program
goto exit

10、mysql中如果是按照主键分组,则select中可以出现其他字段。如果不是按照主键分组,则select中查询的字段必须在group by中出现。

SELECT bs.name,SUM(a.score) AS total_score,a.workdate 
FROM rt_branch_permission b 
LEFT JOIN (SELECT score,workdate,ehrno FROM rt_djdb_data WHERE workdate LIKE '2022-01%') a  
ON a.ehrno=b.ehrno 
LEFT JOIN bank_staff bs 
ON b.ehrno = bs.ehr 
WHERE bs.org_id = '16689' 
GROUP BY b.ehrno 
ORDER BY total_score DESC;

11、取余
在这里插入图片描述

12、js打开一个新页面
window.open([URL], [窗口名称])
URL:可选参数,在窗口中要显示网页的网址或路径。如果省略这个参数,或者它的值是空字符串,那么窗口就不显示任何文档。
窗口名称:可选参数,被打开窗口的名称。
1.该名称由字母、数字和下划线字符组成。
2."_top"、"_blank"、"_selft"具有特殊意义的名称。
_blank:在新窗口显示目标网页
_self:在当前窗口显示目标网页
_top:框架网页中在上部窗口中显示目标网页

13、获得当前项目所在的path
requst.getSession().getServletContext().getRealPath("/")

D:\soft\tomcat\apache-tomcat-8.0.53\webapps\UAP\

14、Mybatis对MySQL中BLOB字段的读取
1、在sqlMapConfig中,定义一个typeHandlers

<typeHandlers>
<typeHandler jdbcType="BLOB" javaType="byte[]" handler="org.apache.ibatis.type.BlobTypeHandler"/>
</typeHandlers>

2、在mapper里面定义resultmap的result column

	<select id="getOnePDF" parameterType="map" resultMap="getOnePDF">
    		SELECT fjnr FROM tc_print WHERE MKDM=#{mkdm} and YWBH=#{ywbh} and YWLSH=#{ywlsh}
    </select>
    
    <resultMap type="com.etc.entity.ByteArrOfPDF" id="getOnePDF">
    	<result column="fjnr" property="fjnr" jdbcType="BLOB"  typeHandler="org.apache.ibatis.type.BlobTypeHandler" />
    </resultMap>

15、jquery触发事件的两种写法

$("button").click(function(){
  $("p").slideToggle();
});

$("button").bind("click",function(){
  $("p").slideToggle();
});

16、分页

int start=(pageNo-1)*pageSize;
int end=pageNo*pageSize;//orcle需要这样写
int end=pageSize;//mysql直接表示页面大小
int totalPage=(totalCount%pageSize==0)?totalCount/pageSize:totalCount/pageSize+1;
List<PrintPDFResp> PDFList = printPDFsDao.queryPagedprintPDFsInfo(start,end,selectValue);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值