代码杂记(三)

1

界面设计中尽量少用粗体.

还有url中的參数不用再加引號,如:

method=registProtocol   不能写成method=‘registProtocol’

2.

Js获取设置一个元素的位置:

   var div = document.getElementById("minimapDiv");

       div.style.top = div.offsetTop;

       div.style.left = div.offsetLeft;

jquery获取设置一个元素的位置:

    var div = $("#minimapDiv");

     var top = div.position().top;

     var left = div.offset().left;

      div.css("top",top);

    div.css("left",left);

3.

//var agent = window.navigator.appName; //不能用appName进行浏览器推断。由于iechromeappName都是Netscape

 var userAgent = window.navigator.userAgent.toUpperCase();

 if(userAgent.indexOf("CHROME") == -1) { //chrome浏览器

   }else{}

4.

Shift+tab:向前缩进(4个字符为准)

Tab:向后缩进(4个字符为准)

Ctrl+shift+r:查找

Ctrl+/:凝视

Ctrl+d:删除当前行

Ctrl+alt+:凝视

Home:行头

End:行尾

5.

java代码设置缓存:

public static Map<String, Object> cacheMap = new HashMap<String, Object>();//用于缓存已经查询过的字段信息

if (cacheMap .get(cacheId)!=null) { //缓存中有,则拿取

return (ProtocolFieldVO)cacheMap .get(cacheId);

}

cacheMap.put(cacheId, vo);//缓存中没有,则设置

6.

出现:<Could not get the server file lock. Ensure that another server is not running in the same directory. Retrying for another 60 seconds.>

关掉javaw.exe进程

7.

Form表单提交,想要有运行后的提示信息和跳转页面。能够採用:

response.getWriter().print("
<script>alert('加入成功');
<span style="font-family:宋体;">              </span>window.setTimeout(function(){location.href = '/pis/preset/regProtocolMgrAction!getRegistedProtocolInfo.action';},1000);
</script>");

假设是ajax或者post请求,就能够在回调函数中alert().







原文地址:https://www.cnblogs.com/blfbuaa/p/6707620.html