知识点总结-2018.05.23

1.jstl 引入其他jsp页面

   <a data-toggle="tab" id="tap11" href="#tab1">建模</a>
   <div id="tab1" class="tab-pane in active"><c:import url="project_work_1.jsp"></c:import></div>

2. 得到tomcat项目发布路径(不知道(2)什么意思)

     (1)httpServletRequest.getRealPath("/")
	 (2)public static String getClasspath(){
			String path = (String.valueOf(Thread.currentThread().getContextClassLoader().getResource(""))+"../../").replaceAll("file:/", "").replaceAll("%20", " ").trim();	
			if(path.indexOf(":") != 1){
				path = File.separator + path;
			}
			return path;
		}

3.数组转List

 Arrays.asList()

4.diaglog的基本用法

    function addPeriod(Id){
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL ='<%=basePath%>period/goAdd.do?tab=${pd.period_type}&OID='+Id;
			 diag.Width = 400;
			 diag.Height= 300;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
						
					 	setTimeout("self.location.reload()",100);
						top.jzts();
						
				}
				diag.close();
			 };
			 diag.show();
	}

5.jquery juqery 遮罩

    top.jzts();   //如果网页出错屏蔽网页的操作
    $(top.hangge());   //清除屏蔽网页的动作

6.你猜是什么

    ModelAndView mv = this.getModelAndView();
    mv.addObject("varlist", list);
	mv.addObject("varlistworker", listworker);
	mv.addObject("varlist1", list1);
	mv.addObject("varlistworker1", listworker1);
	mv.addObject("varlist2", list2);
	mv.addObject("varlistworker2", listworker2);
	mv.addObject("varlist3", list3);
	mv.addObject("varlistworker3", listworker3);
			
			
	<c:forEach begin="1" end="3" step="1" varStatus="status">
		<c:set var="varIndex" scope="page" value="varlist${status.index}"/>
		<c:set var="varIndex1" scope="page" value="varlistworker${status.index}"/>
		<c:set var="dataList" scope="request" value="${requestScope[varIndex]}"/>
		<c:set var="dataList1" scope="request" value="${requestScope[varIndex1]}"/>
		
		<div id="tab${status.index}" class="tab-pane <c:if test="${status.index == 1}">in active</c:if>">
			<c:import url="project_work.jsp">
				<c:param name="periodType" value="${status.index}"></c:param>
			</c:import> 
		</div>
	</c:forEach>

7.controller方法之间相互跳转

    return new ModelAndView("redirect:/project/goView.do?OID="+projectOID+"&titleProjectWork="+titleProjectWork);	

8.带参数的请求转发

@RequestMapping(value="/redirect",method=RequestMethod.GET)  
public String testRedirect(RedirectAttributes attr){  
     attr.addAttribute("a", "a");  
     attr.addFlashAttribute("b", "b");  
     return "redirect:/index.action";  
}  

9.sprng < form:check > 使用
这里写链接内容

10.模糊查询

<if test="name != '' and name !=null">
         and a.name LIKE CONCAT('%', #{name}, '%')
</if>

11.引入sql

<sql id="systemParamColumns">
        a.id,
        a.name,
        a.code,
        a.value,
        a.unit,
        a.type AS "dict.value",
        b.label AS "dict.label",
        a.remarks,
        a.create_by AS "createBy.id",
        a.create_date,
        a.update_by AS "updateBy.id",
        a.update_date,
        a.del_flag
    </sql>

    <sql id="systemParamJoins">
        LEFT JOIN sys_dict b ON a.type = b.value AND b.type = #{dict.type}
    </sql>

    <select id="get" resultType="KfSystemParam">
        SELECT
          <include refid="systemParamColumns"/>
        FROM kf_system_param a
          <include refid="systemParamJoins"/>
        WHERE a.id = #{id}
    </select>
    
    <select id="findList" resultType="KfSystemParam">
        SELECT
          <include refid="systemParamColumns"/>
        FROM kf_system_param a
        <include refid="systemParamJoins"/>
        WHERE a.del_flag = #{DEL_FLAG_NORMAL}
        <if test="name != null and name != ''">
            AND a.name LIKE CONCAT('%', #{name}, '%')
        </if>
        ORDER BY a.id DESC
    </select>

12.字体库
http://fontawesome.io/icons/

13.jquery获取值
https://www.cnblogs.com/xiaolinxi/p/5179086.html
https://www.cnblogs.com/aiqingqing/p/5048854.html

14.未知
http://blog.csdn.net/mrw456/article/details/50408649
https://www.cnblogs.com/ranzige/p/4258549.html
http://www.wufangbo.com/jquery-validation/
https://jqueryvalidation.org/documentation/
https://jqueryvalidation.org/validate/

15.Mustache.js
http://blog.csdn.net/xuemoyao/article/details/17896203
http://blog.sina.com.cn/s/blog_a18312650101iygw.html
基本用法

<script type="text/template" id="collectionTpl">
	{{row.参数}}
	{{#row.参数}}
	有值时显示
	{{/row.参数}}
	{{^row.参数}}
	无值时显示
	{{/row.参数}}
</script>

js:

 var tpl = $("#collectionTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");//替换空格和换行
 $.each(response.data,function() {
     $("#work-List").append(Mustache.render(tpl, {
         row: this
     }));
 })

16.获取最新插入数据的id

<insert id="insert" parameterType="KfCustomerSystem" useGeneratedKeys="true" keyProperty="id">
		<selectKey resultType="string" keyProperty="id" order="AFTER" >
			SELECT LAST_INSERT_ID() AS id
		</selectKey>
		insert into kf_customer_system (
				name
			)values(
				#{name}
			)
	</insert>

或:

<insert id="insert"  useGeneratedKeys="true" keyProperty="id" parameterType="KfNotification"></insesrt>

17.获取以某字符串开头的id

$("li[id^='customerSystemWater_']").attr("id");

18.获取包含某字符串开头的id(没测过)
tr包含cell的id

$('tr[id*="cell"]');

tr以cell开关的id

	$('tr[id^="cell"]');

tr以cell结尾的id

	 $("tr[id$='cell']);

19.模态框关闭事件 模态框id

$('#customer-system-modal').on('hide.bs.modal', function () {
alert('嘿,我听说您喜欢模态框...');
})
//模态框开启事件
$('#customer-system-modal').on('show.bs.modal', function () {
alert('嘿,我听说您喜欢模态框...');
})

20.模态框上加style="z-index:111111"防止被其他模态框覆盖

21.判断是不是数字

int id = 0;
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(kfWaterAlarm.getId());
if( !isNum.matches() ){
   System.out.print("false");
}else{
   System.out.print("true");
}

22.jsp 定义对象

var content = new Array();content.push(arry);

controller接收:

String jsonStr = pd.getString("content");
JSONArray jsonArray = JSONArray.fromObject(jsonStr);
     for(int i = 0 ; i < jsonArray.size() ; i++){
		  JSONObject obj = (JSONObject) jsonArray.get(i);
		  obj.getString("id")
	 }

23.jstl 数组大小

${fn:length(viewList)-1}

24.Java读取properties(请忽略这条,该条错误)

@Value("${adminPath}")
protected String adminPath;

25.chosen(select 控件)解决ajax 不能赋值问题

$("#subclientSelect").trigger("liszt:updated"); 

26.

$.contains();比较标签
:contains();判断包含的指定字符串

例如:

//不包含
$("p:not(:contains(is))").css("background-color","yellow");
//包含
$("p:contains(is)").css("background-color","yellow");

27.下载路径(请忽略这条,该条错误)

 httpServletRequest.getRealPath("/")

28.实时监听input的值变化

$("#search").bind("input propertychange",function(){});

29.mybatis 传参 重点是@Param(“参数”)

 //java
 Public User selectUser(@param(“userName”)String name,@param(“userArea”)String area);
 //sql
 <select id=" selectUser" resultMap="BaseResultMap">
   select  *  from user_user_t   where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR}
</select> 

30.jq 获取整个标签

//全部获取(包含该标签,内部内容)
$(this).prop("outerHTML")
//获取该标签内部内容
$(this).prop("innerHTML")

31.jquery on的绑定事件传参数

var clickEven = [
	{id:"#water-effect-list1",class:".dict-water-effect",list:"#water-effect-list2"},
	{id:"#water-effect-list2",class:".dict-water-effect",list:"#water-effect-list1"},
	{id:"#water-quality-list1",class:".customer-water-quality",list:"#water-quality-list2"},
	{id:"#water-quality-list2",class:".customer-water-quality",list:"#water-quality-list1"},
	{id:"#online-item-list1",class:".customer-online-item",list:"#online-item-list2"},
	{id:"#online-item-list2",class:".customer-online-item",list:"#online-item-list1"},
	{id:"#system-chemical-list1",class:".customer-system-chemical",list:"#system-chemical-list2"},
	{id:"#system-chemical-list2",class:".customer-system-chemical",list:"#system-chemical-list1"}
];
for(var  i = 0 ; i < clickEven.length ; i++){
	$(document).on("click",clickEven[i].id +" "+clickEven[i].class,{list:clickEven[i].list},function(even){
		var str = $(this).prop("outerHTML");
		$(even.data.list).append(str);
		$(this).remove();
	})
}

32.mysql 对时间操作

select 
create_date
from 
kf_alarm_task 
where 
create_date
BETWEEN
date_add(now(), interval -1 day)//的到前一天的时间
AND
now()
//或
select date_add(now(), interval -1 day);

//查询你某天一天之前
SELECT * FROM employee WHERE hire_date < '2000-1-1 11:11:11'

//距今大于24小时
WHERE 
HOUR(timediff(now(),a.create_date))> 24

//
select
*
from 
(
SELECT
a.id,
a.task_id as taskId,
a.task_status,
a.remarks,
a.create_by AS "createBy.id",
max(a.create_date) as "create_date",
u.name AS "userName",
a.flag,
u.name AS "createBy.name"
FROM kf_task_process a
Left JOIN sys_user u ON u.id = a.create_by
where a.task_status in ('0','1','2')
GROUP BY a.task_id
) as b
where
HOUR(timediff(now(),b.create_date))> 24

33.字符串拼接

Java :StringBuffer
jquery :?.concat(?,?)

34.bind 和on的区别
http://blog.csdn.net/aitangyong/article/details/43673535

35.设置点击时间

var time = 0;
$('button').click(function() {
    //判断计时器是否处于关闭状态
    if (time == 0) {
        time = 10; //设定间隔时间(秒)
 
        //启动计时器,倒计时time秒后自动关闭计时器。
        var index = setInterval(function(){
            time--;
            if (time == 0) {
                clearInterval(index);
            }
        }, 1000);
 
        alert('按钮事件被触发');
    }else{
        alert('目前按钮事件不允许被触发');
    }
});

36.

<!-- 插入用户和角色关联表数据 -->
	<insert id="insertUserRole">
		INSERT INTO sys_user_role(user_id, role_id)
		<foreach collection="roleList" item="role" separator=" union all ">
			SELECT #{id}, #{role.id}
			<if test="dbName != 'mssql'">
			FROM dual
			</if>
		</foreach>
	</insert>

37.query 全面不替换
1.例如:var a=‘12,13,14,15’;现在想把字符串替换,号为-
我们发现,jquery中的replace方法:a.replace(",","-");只能替换掉第一个,号。即,结果为12-13,14,15
jquery中是没有对字符串进行replaceAll的方法,通常这个时候,全部替换采用正则表达式的方式替换。如下:

var reg = new RegExp(",","g");//g,表示全部替换。
a.replace(reg,"-");
//结果:12-13-14-15
var str='aabbccaa';
var reg=/aa/g;
str=str.replace(reg,'dd');
//结果是 str='ddbbccdd'

38.select 事件

<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("input").select(function(){
    $("input").after(" Text marked!");
  });
});
</script>

<input type="text" name="FirstName" value="Hello World" />
<p>请试着选取输入域中的文本,看看会发生什么。</p>

38.mysql in查询时 赋值时用${},不能用#{}

39.html 缓存的用法

(1)这个写法可能会不对
//赋值
function cl(msg){
	if(window.localStorage){
		localStorage.setItem("usermsg",msg);
	}else{
		Cookie.write("usermsg",msg);
	}
}
//取值
var str = window.localStorage?localStorage.getItem("usermsg"):Cookie.read("usermsg");

(2)这个亲测有效

if(window.localStorage){
	localStorage.setItem("usermsg",JSON.stringify(response.data));
}else{
	Cookie.write("usermsg",JSON.stringify(response.data));
}
var str = window.localStorage?localStorage.getItem("usermsg"):Cookie.read("usermsg");
console.log(JSON.parse(str));//转化成json

40.spring-boot启动类 读取配置文件
https://blog.csdn.net/gaolu/article/details/52708177

41.net.sf.json Maven依赖配置

<dependency>    
    <groupId>net.sf.json-lib</groupId>    
    <artifactId>json-lib</artifactId>    
    <version>2.4</version>    
    <classifier>jdk15</classifier>//不带这个会报错    
</dependency>  

42.tomcat 启动war server.xml < host >< /host>节点下加入

<Context  path ="chapter-05"  reloadable ="false"  docBase ="F:/GS.war"  workDir ="F:/GS"  />

(主意:war包要加扩展名,之前就是因为这个问题搞了两个钟头,网上的都是胡说八道,TNND)
43.MySql开启远程访问
https://blog.csdn.net/bingjianit/article/details/54384299
先说说这个错误,其实就是我们的MySQL不允许远程登录,所以远程登录失败了,解决方法如下:

在装有MySQL的机器上登录MySQL mysql -u root -p密码
执行use mysql;
执行update user set host = ‘%’ where user = ‘root’;这一句执行完可能会报错,不用管它。
执行FLUSH PRIVILEGES;

经过上面4步,就可以解决这个问题了。
注: 第四步是刷新MySQL的权限相关表,一定不要忘了,我第一次的时候没有执行第四步,结果一直不成功,最后才找到这个原因。

44.sql 行列互换
https://blog.csdn.net/jackfrued/article/details/45021897

45.springBoot maven 打包jar报错
出现这个问题主要是因为打包package遇到test会冲突(冲突解释不准确),在打包的时候跳过test就可以了

mvn package -DskipTests

46

       select
		  	a.kfCustomerSystemWaterName,
			a.kfCustomerSystemWaterQualityId,
		<foreach collection="list" index="index" item="item" open="" separator="," close="">
			(case when a.kfSystemWaterQualityName = #{item} then a.kfcsWaterQualityReal end) as #{item}
		</foreach>
        from
		(select
			b.id,
			d.id as "kfCustomerSystemWaterId",
			d.name as "kfCustomerSystemWaterName",
			c.id as "kfCustomerSystemWaterQualityId",
			f.`name` as "kfSystemWaterQualityName",
			g.real as "kfcsWaterQualityReal"
		from kf_weekly_water_quality a
		left join kf_weekly b on a.weekly_id = b.id
		LEFT join kf_weekly_template_water_quality c on a.weekly_template_water_quality_id = c.id
		left join kf_customer_system_water d on c.customer_system_water_id = d.id
		left join kf_customer_water_quality e on c.customer_system_water_quality_id = e.id
		LEFT JOIN kf_water_quality f on e.water_quality_id = f.id
		left join kfcs_water_quality g on e.id = g.customer_system_water_quality_id) as a

shadowsocket免费账号分享
地址一:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值