try{
update1 = jdbcTemplate.update(sql1, bnAtcDiagrams.getID_());
}catch (Exception e){
e.printStackTrace();
//获取异常信息 //是否包含异常关键信息,如果是true则包含
boolean bo = e.getMessage().contains("MySQLIntegrityConstraintViolationException");
if(bo){
return -2;
}
return -1;
}
//List
$.ajax({
type: "post",
url: "topupRecordController.do?updateReceiptInfo",
data: {
refNo:rowsData[0].refNo
},
dataType: "json",
success: function(result){
}
});
//把字符串str的/替换成,
str.replaceAll("/", ",");
//截取字符串str第一位
str.subSequence(0, 1);
//去掉最后一位数
str.substring(0, name.length() - 1);
//字符串转换时间
SimpleDateFormat firstDay= new SimpleDateFormat("yyyy-MM-dd");
Date parse =parse = firstDay.parse(parasMap.get("overtimeDate").toString());
String regex = "\\{([^}]*)\\}";
Pattern pattern = Pattern.compile (regex);
Matcher matcher = pattern.matcher (resolveText);
while (matcher.find ())
{
System.out.println ();
for (MessageItem messageItem : messageItems) {
System.out.println (matcher.group ().substring(1,matcher.group ().length()-1)));
}
}
$('#testSelect option:selected').text();//选中的文本
$('#testSelect option:selected') .val();//选中的值
$("#testSelect ").get(0).selectedIndex;//索引
//第一种直接赋值
var start_Time = new Date(值).pattern("yyyy/MM/dd HH:mm:ss");
//第二种标签
$("input[name='urlPath']").val();
$("input[name='jump']:checked").val();
input ztree下拉选择框
//选择事件
function S_NodeChecks(e, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId),
nodes = zTree.getCheckedNodes(true)
var ids = '', names = ''
for (var i = 0; i < nodes.length; i++) {
ids += '&'+ nodes[i].id
names += '&'+ nodes[i].name
}
if (ids.length > 0) {
ids = ids.substr(1), names = names.substr(1)
}
var $from = $('#'+ treeId).data('fromObj')
if ($from && $from.length){
$from.val(names);
$("#j_tag_parent_id").val(ids);
$.CurrentDialog.find("#default_label_value").val(ids);
}
}
//单击事件
function S_NodeClicks(event, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId)
zTree.checkNode(treeNode, !treeNode.checked, true, true)
event.preventDefault()
}
获取当前月的第一天以及最后一天
//获取本月第一天以及最后一天
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
SimpleDateFormat firstDay= new SimpleDateFormat("yyyy-MM-dd");
String format = firstDay.format(calendar.getTime());
Date firstDate = firstDay.parse(format);//本月第一天
calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
String format1 = firstDay.format(calendar.getTime());
Date lastDate = firstDay.parse(format1);//本月最后一天
for (Integer in : map.keySet()) {
23 //map.keySet()返回的是所有key的值
24 String str = map.get(in);//得到每个key多对用value的值
25 System.out.println(in + " " + str);
26 }
(function ($) {
$.fn.extend({
insertAtCaret: function (myValue) {
var $t = $(this)[0];
if (document.selection) {
this.focus();
sel = document.selection.createRange();
sel.text = myValue;
this.focus();
} else
if ($t.selectionStart || $t.selectionStart == '0') {
var startPos = $t.selectionStart;
var endPos = $t.selectionEnd;
var scrollTop = $t.scrollTop;
$t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
this.focus();
$t.selectionStart = startPos + myValue.length;
$t.selectionEnd = startPos + myValue.length;
$t.scrollTop = scrollTop;
} else {
this.value += myValue;
this.focus();
}
}
})
})(jQuery);
以上为方法的固定写法!通过调用来实现!
$("赋值的文本框ID").insertAtCaret(赋值的内容);
以上方法即可实现
ztree的js定义使用:
$(function(){
var tree3;
var setting = {//设定setting 的配置
check: {
enable: true,//开启选择框
chkStyle: "radio",//单选
radioType: "all"
},
view: {
selectedMulti: false
},
data: {
simpleData: {
enable: true
}
},
callback: {
/*
beforeClick: function (id, node) {
tree.checkNode(node, !node.checked, true, true);
return false;
},*/
onCheck: function (e, treeId, treeNode) {//选择事件
var zTree = $.fn.zTree.getZTreeObj(treeId),
nodes = zTree.getCheckedNodes(true);
var ids = '', names = '';
for (var i = 0; i < nodes.length; i++) {
ids += ',' + nodes[i].id;
names += ',' + nodes[i].name;
}
if (ids.length > 0) {
ids = ids.substr(1), names = names.substr(1);
}
var $from = $('#' + treeId).data('fromObj');
if ($from && $from.length) {
$from.val(names);
$("#j_tag_parent_id").val(ids);
}
},
//单击事件
onClick: function (event, treeId, treeNode) {//单机事件
var zTree = $.fn.zTree.getZTreeObj(treeId);
zTree.checkNode(treeNode, !treeNode.checked, true, true);
event.preventDefault();
}
} //这里是节点点击事件
};
var zNodes1 = [//获取参数节点配置方法
{
id: "${menu.id}",
pId: "${not empty menu.parent_id?menu.parent_id:0}",
name: "${not empty menu.parent_id?menu.name:'权限列表'}"
},//,isParent:true
];
// 初始化树结构
tree3 = $.fn.zTree.init($.CurrentNavtab.find("#j_select_tree30"), setting, zNodes1); // 默认选择节点
var node = tree3.getNodeByParam("id", ${parent_id});//查询节点
var nodes = tree3.getNodeByParam("id", ${id});
try {
$.CurrentNavtab.find("#j_tag_parent_name").val(node.name);
tree3.checkNode(node, true, false);//选中父级操作
tree3.removeNode(nodes);//删除本身操作
} catch (e) {
}
// 默认展开全部节点
tree3.expandAll(true);
})
回车事件
//body定义方法
onkeydown="keyLogin();"
function keyLogin(){
if (event.keyCode==13){
$("#accountLoginBtn").click(); //调用登录按钮的登录事件,按钮id
} //回车键的键值为13
}
--------------------------------------------通用----------------------------------分割线-------------------------------
form表单提交后的回调操作
//form标签内定义属性
data-callback="msg_task_save_success"
//函数方法
function msg_task_save_success(json) {
//操作成功
if (json.statusCode == 200) {
//刷新父页签
$.CurrentNavtab.navtab("refresh", "");
} else {
$(this).alertmsg("error", json.message, {title: "提示", displayPosition: "topcenter"})
}
}
查看操作详情代码请见LAYUI页面生成篇,地址
https://blog.csdn.net/distinctive_MAN/article/details/89091605