杂记随笔

目录标签出现问题
请查看右侧目录栏
在这里插入图片描述

电脑使用基础快捷键

win10自带的输入法输入时候变成繁体字

ctrl+shift+f 组合键可以进行简体字和繁体字的切换。

输入的时候,输入一个字后面的字就消失了

正常情况 输入模式为【插入】模式 按一下 insert 按钮 切换成 【覆盖】模式 , 会覆盖掉后面的内容 , 再按一下insert按钮 , 切换回【插入】模式就好了

好用工具

截图工具:snipaste

微软商店搜索:snipaste 安装启用后
截图: 按一下 F1 按钮 自动截图

压缩解压工具 : bindzip

无广告,无弹窗 ,速度超快
在这里插入图片描述

链接:https://pan.baidu.com/s/1Zv5NRl9FNee0_RSa_vIf2A
提取码:f6yc

一键强制卸载工具 :geek

安装数据库时候 , 如果装错了 是不是特别麻烦 , geek能把注册表等文件都给一键删除
在这里插入图片描述

链接:https://pan.baidu.com/s/1JeOLK3WiQt4Enbycb6GndA
提取码:nkrt

配置相关

idea配置maven

注意点:
配置环境变量 , 使用mvn -version命令查看是否成功配置
修改setting文件 , 设置依赖下载的本地仓库 , 设置国内下载阿里云镜像 , 注意修改本地仓库的时候要复制出来,不然会被注释掉
在IDEA中的setting / Maven 中
在这里插入图片描述

参考文档:关于IDEA配置maven环境

idea配置Git

安装教程:Git的安装与使用教程(超详细!!!)

IDEA配置及使用Git:idea配置git步骤

IDEA克隆项目: git / clone 进入页面 导入ssm项目需要配置Maven 和 tomcat
idea从首次从git上clone项目的步骤及配置运行项目

低级错误: 少写一个 } 引发的惨案

在这里插入图片描述
系统提示该位置不允许使用注解, 一开始以为是注解的问题 , 然后右边日志说 lombok失效,然后一堆操作之后还是不行

最后发现所有报错都是在这个类里面的 ,说明是这个类的什么地方出问题了 , 并且 ,看图中括号报错了, 参数也说找不到 , 所以推测是什么地方代码错了,

果然最后找到爆红的第一行 ,然后发现上一个方法的括号少写了一个 ,加上 } 不再爆红 , 推荐两个IDEA插件
idea彩虹括号插件
IDEA安装阿里代码规范插件

数据库连接错误引发的问题

早上到公司打开项目 , 运行时候报了下面的错误信息

ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'caseAutoPullService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.thinkgem.jeesite.modules.auto.utils.RequestAndHandleJsonService com.thinkgem.jeesite.modules.auto.service.CaseAutoPullService.requestAndHandleJsonService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestAndHandleJsonService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.thinkgem.jeesite.modules.accident.dao.CaseAccidentDao com.thinkgem.jeesite.modules.auto.utils.RequestAndHandleJsonService.caseAccidentDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.thinkgem.jeesite.modules.accident.dao.CaseAccidentDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.thinkgem.jeesite.modules.accident.dao.CaseAccidentDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

在这里插入图片描述
在这里插入图片描述
在网上看到很多解释

  • 有配置文件错误
  • 是否添加@Controller注解,检查对应的service是否添加了@Service(“xxxService”)注解’’
  • 自己注入自己了
  • web.xml文档的配置不对,
  • bean配置的不正确或漏掉,
  • JDBC错误

后来求助师傅 ,师傅看报错信息主要是Dao层与Server层报错 ,然后使用Git的查看历史修改工具, 发现代码没有问题 , 然后使用navcat测试数据库连接 ,发现连接没有问题,数据库正常连接 , 然后就用测试类测试数据库连接, 发现报错: 说明还是IDEA与数据库连接的问题
在这里插入图片描述
公司项目使用的mysql版本是mysql5.7 我一开始装的是mysql8.0 , 和公司的版本不一样 , 所以又装了一个mysql5.7 。 昨天也是报这个错,但是我没有想起来 ,打开服务,果然发现现在运行的是mysql8.0 。
在这里插入图片描述
关闭8.0 服务 ,打开 5.7的服务 ,再次运行 ,成功,无报错

navicat运行sql文件出现错误 , 报错文件过大 ,无法加载

解决方案:
找到MySQL安装地址的my.ini文件
在这里插入图片描述
添加上红色框中的一行
在这里插入图片描述
参考文件:Mysql的max_allowed_packet设定

IDEA全局搜索快捷键

双击shift 开启
在这里插入图片描述

IDEA 快速定位类中的方法

在这里插入图片描述

IDEA的debug步骤

  • 在程序中打上断点 ,debug启动 ,然后程序在断点会自动停下 ,控制栏里会显示方法和参数信息

在这里插入图片描述

IDEA 多行编辑

按住 :Ctrl + Shift 然后用鼠标点击多处

jsp相关

有关jsp中 <form:select 标签的内容

form:select 遍历后台List集合 生成select下拉选择器

		<div class="control-group">
			<label class="control-label">事故认定原因分类:</label>
			<div class="controls">
<%--			path: 实体中的字段	form:select  遍历后台List集合 生成select下拉选择器--%>
				<form:select path="weatherType" class="input-xlarge required">
					<form:option value="" label=""/>
<%--			    items: 表示将要遍历的表  itemLabel: 显示的文本  itemValue: 文本的值  htmlEscape: 字符转义--%>
					<form:options items="${fns:getDictList('weather_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

path:表示实体类中的某个字段
items:表示将要遍历的表
itemLabel:表示显示的内容
itemValue:内容的值 , 比如代表的数字
${fns:getDictList()}:表示的是数据字典相关内容

htmlEscape=“false” ,起转义作用 , 输入内容 “<” ; 输出也能是 <
springmvc常用标签form:select
SpringMVC 表单标签中 htmlEscape 属性的作用

< c:forEach循环控制标签

								<select id="caseUserInfoList{{idx}}_faultObject"  name="caseUserInfoList[{{idx}}].faultObject" data-value="{{row.faultObject}}" class="input-small">
									<option value=""></option>
									<c:forEach items="${fns:getDictList('fault_object')}" var="dict">
										<option value="${dict.value}">${dict.value} ${dict.label}</option>
									</c:forEach>
								</select>

option 元素定义下拉列表中的一个选项(一个条目)。

IDEA 开启 jsp 热部署

SSM项目热部署 , 在配置tomcat的时候 , 选择war exploded

war 和war exploded的区别
war模式:将WEB工程以包的形式上传到服务器 ;
war exploded模式:将WEB工程以当前文件夹的位置关系上传到服务器;
在这里插入图片描述
在这里插入图片描述
点击旋转按钮 ,会弹出几个选项 , 选择resource 就可以
这样在修改 JSP 页面就不用重新启动tomcat
在这里插入图片描述

fns.tld 文件 ,<%@ taglib 引入

1、首先要有一个fns.tld 文件

<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
  version="2.0">
    
  <description>JSTL 1.1 functions library</description>
  <display-name>JSTL functions sys</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>fns</short-name>
  <uri>http://java.sun.com/jsp/jstl/functionss</uri>
  
  <function>
    <description>获取字典对象列表</description>
<!--    jsp通过name属性找到这个方法-->
    <name>getDictList</name>
<!--    类的地址-->
    <function-class>com.thinkgem.jeesite.modules.sys.utils.DictUtils</function-class>
<!--    调用哪一个java方法-->
    <function-signature>java.util.List getDictList(java.lang.String)</function-signature>
<!--    在JSP中通过什么格式调用-->
    <example>${fns:getDictList(type)}</example>  
  </function>
  
</taglib>

2、在jsp页面中引入 fns.tld 文件

<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>

3、在jsp中使用fns.tld文件中定义的方法 "value " 与 “label” 要和实体类中名字一样

<form:options items="${fns:getDictList('weather_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>

4 、 后台java方法, 获取字典列表

	public static List<Dict> getDictList(String type){
		@SuppressWarnings("unchecked")
		Map<String, List<Dict>> dictMap = (Map<String, List<Dict>>)CacheUtils.get(CACHE_DICT_MAP);
		if (dictMap==null){
			dictMap = Maps.newHashMap();
			for (Dict dict : dictDao.findAllList(new Dict())){
				List<Dict> dictList = dictMap.get(dict.getType());
				if (dictList != null){
					dictList.add(dict);
				}else{
					dictMap.put(dict.getType(), Lists.newArrayList(dict));
				}
			}
			CacheUtils.put(CACHE_DICT_MAP, dictMap);
		}
		List<Dict> dictList = dictMap.get(type);
		if (dictList == null){
			dictList = Lists.newArrayList();
		}
		return dictList;
	}

5、有一个字典的实体类 , jsp中j获取属性要和这里一样

public class Dict extends DataEntity<Dict> {

	private static final long serialVersionUID = 1L;
	private String value;	// 数据值
	private String label;	// 标签名
	private String type;	// 类型
	private String description;// 描述
	private Integer sort;	// 排序
	private String parentId;//父Id
}

form失去焦点事件 :onblur = “方法名”

js

function linkage1(idx){ }

html

οnblur="linkage1({{idx}})"  //会在对象失去焦点时发生 , 鼠标移开的时候。

Onblur的点击事件

后端Java相关

StringUtils.isBlank(“abc”)与StringUtils.isEmpty("")

isBlank: 判断某字符串是否为空或者长度为0或由空白符(whitespace)构成
isEmpty : 判断某字符串是否为空,为空的标准是str == null或str.length() == 0

参考博客:isEmpty和isBlank的区别

model.addattribute()的作用

作用: 1.往前台传数据,可以传对象,可以传List,通过el表达式 ${}可以获取到,
在这里插入图片描述


	<form:form id="inputForm" modelAttribute="caseAccident" action="${ctx}/accident/caseAccident/save" method="post" class="form-horizontal">

HTML中Form表单的使用

@ModelAttribute注解

  • 放在方法上面 , 这个类 中所有方法在执行之前都会先执行被注解的这个方法 , 如下会先根据ID获取字体类
  • 放在方法参数前 , 用来封装前端页面传递过来的“对象属性”的 ,将属性封装在对象里面。
	@ModelAttribute
	public CaseAccident get(@RequestParam(required = false) String id) {
		CaseAccident entity = null;
		if (StringUtils.isNotBlank(id)) {
			entity = caseAccidentService.get(id);
		}
		if (entity == null) {
			entity = new CaseAccident();
		}
		return entity;
	}

@ModelAttribute用法详解

@ModelAttribute 注释在方法参数里面

mybatis多个参数传递 : @param

再Dao层映射到mybatis的时候 , 如果传了多个参数作为数据库的条件 , 那么需要为这些参数设置对应的key名称

常用: 使用@Param注解

	//三级联动
	List<Dict> findDictByValue(@Param("value") String value,@Param("type") String type);
<!--	三级联动-->
    <select id="findDictByValue" resultType="com.thinkgem.jeesite.modules.sys.entity.Dict">
		SELECT *
		FROM sys_dict
		WHERE
			del_flag = '0'
		  AND
		     type = (#{type})
		  AND
			`value` like concat(#{value},'%')
		ORDER BY sort
	</select>

@param注解用法解析

Mybatis传递多个参数的4种方式(干货)

json 与 java 的转化

参考文献: Json详解以及fastjson使用教程

Enumeration params = request.getParameterNames();

Request.getparameternames 作用

request.getHeader(“referer”)

request.getHeader(“Referer”)中的Referer是从哪里来的?

redirectAttributes.addFlashAttribute
springboot -重定向携带数据 RedirectAttributes

@Transactional(readOnly = false)

@Transactional(readOnly=false)

spring 事务管理之只读事务@Transactional(readOnly = true)

XStream xStream = new XStream(new DomDriver());

XStream的简单使用
@XStreamAlias理解和使用

Boolean.parseBoolean(string);

Boolean.parseBoolean(string);

Object[] params = new Object[] {getXML(phone,content)};

Object[ ]params=new Object[ ]{ };详细解释!!!

system.currentTimeMillis()

由system.currentTimeMillis() 获得当前的时间

多条数据、多个字段批量更新

生成一条sql语句

	<update id="updateList" parameterType="list">
		update assignment_processor
		<trim prefix="set" suffixOverrides=",">
			<if test="accidentHanding != null and accidentHanding == 1">
				num = 0,
				<trim prefix=" num2 =case user_id" suffix="end,">
					<foreach collection="processorList" item="item" index="index">
						<if test="item.userId!=null">
							when #{item.userId} then #{item.num2}
						</if>
					</foreach>
				</trim>
			</if>
			<if test="accidentHanding != null and accidentHanding == 2">
				num2 = 0,
				<trim prefix="num =case user_id" suffix="end,">
					<foreach collection="processorList" item="item" index="index">
						<if test="item.userId!=null">
							when #{item.userId} then #{item.num}
						</if>
					</foreach>
				</trim>
			</if>
		</trim>
		where
		<foreach collection="processorList" separator="or" item="item" index="index" >
			user_id=#{item.userId}
		</foreach>
	</update>

生成多条sql语句

	<update id="updateList" parameterType="list">
		<if test="accidentHanding != null and accidentHanding == 1">
			<foreach collection="processorList" separator=";" item="item" index="index">
				update assignment_processor
				set  num2 = #{item.num2}
				where user_id=#{item.userId}
			</foreach>
		</if>
		<if test="accidentHanding != null and accidentHanding == 2">
			<foreach collection="processorList" item="item" index="index">
				update assignment_processor
				set num = #{item.num}
				where user_id=#{item.userId};
			</foreach>
		</if>
	</update>
IDEA从新打包运行

在terminal中执行命令:清除之前的包

mvn clean package

然后运行生成新的jar包

最后去生成jar包的位置,在文件夹输入栏中输入cmd
在这里插入图片描述
然后输入命令:

java -jar 名字.jar

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值