fengzhaoyang的博客
fengzhaoyang · 共 13 篇文章
servlet原理
Servlet工作原理 Servlet运行在Servlet容器中,由容器负责Servlet实例的查找及创建工作,并按照Servlet规范的规定调用Servlet的一组方法,这些方法也叫生命周期的方法。具体调用过程如下图所示: Servlet生命周期详解 如上图所示,Servlet的生命周期可以分为四个阶段,即装载类及创建实例阶段、初始化阶段、服务阶段和实例销毁阶段。下面针对每个阶段的编程任务及注意事项进行详细的说明。 (1)装载类及创建实例 客户端向Web服务器发送一个请求,请求的协议及路径必须遵守如下的格式: http://serverip:port/application-path/re…
2014-02-17 14:34 · Java · 评论(0)
通用的校验必填项不能为空(包括input框,单选框,复选框,文本域)
//检查必填字段 //(通用的校验必填项不能为空(包括input框,单选框,复选框,文本域)) var elem = document.getElementById("age"); function checkRequired(elem){ var name = elem.name; if(elem.type == "checkbox" || elem.type == "radio"){ var results=[]; results.numChecked = 0; var input = document.getElementsByTagName("input"); for(var i=0…
2013-08-13 21:45 · JavaScript · 评论(0)
Cookie保存和获取
//getCookie 得到指定名称的cookie的值 var bikky = document.cookie; function getCookie(name) { var index = bikky.indexOf(name + "="); if (index == -1) return null; index = bikky.indexOf("=", index) + 1; var endstr = bikky.indexOf(";", index); if (endstr == -1) endstr = bikky.length; return unescape(bikky.subs…
2013-08-13 21:45 · JavaScript · 评论(0)
html页面显示年月日时分秒和星期几
//-----------------------------方式一--------------------------------------------- <html> <head> <script type="text/javascript"> function startTime(){ var today=new Date(); var strDate=(" "+today.getYear()+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日"); var n_day=today.getDay(); switch(n_day){ case…
2013-08-13 21:44 · JavaScript · 评论(0)
禁止鼠标右键的一些方法
<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" onmouseup=document.selection.empty() oncopy=document.selection.empty() onselect=document.selection.empty()></body> onselectstart="return false" 禁止选择,ondragstart="return false"禁止拖放,…
2013-08-13 21:43 · JavaScript · 评论(0)
去除首尾空格的公用方法
String.prototype.trim = function() { return (this.replace(/^\s+|\s+$/g,"")); } //调用方法 function check(){ var fn = document.getElementById("fileName").value; document.getElementById("fileName").value = fn.trim(); }
2013-08-12 11:44 · JavaScript · 评论(0)
页面加载时获取input框焦点
//当载入这个页面的时候 光标会自动放在id="username"的input框里,不需要你去点击后才出现光标 if(window.attachEvent){ window.attachEvent('onload',init); }else if(window.addEventListener){ window.addEventListener('load',init,false); } function init(){ document.getElementById('username').focus(); }
2013-08-12 11:43 · JavaScript · 评论(0)
js实现页面刷新记住滚动条的位置
Html代码 1.<button onclick="window.location.reload();">reload</button> <!--这种方式刷新会回到顶部--> 2.<button onclick="window.document.execCommand('Refresh');">reload</button> <!--这种方式会记住当前点击事件的位置。-->
2013-08-12 11:39 · JavaScript · 评论(0)
遍历js一个对象的所有属性和方法
//obj是一个js对象。 for(var s in obj){ alert(obj[s]); }
2013-08-12 11:33 · JavaScript · 评论(0)
ajax xmlHttpRequest get post
<script type="text/javascript"> var xmlhttp; function loadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest) {// code for all new browsers xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE5 and IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null)…
2013-08-12 11:29 · JavaScript · 评论(0)
ajax传参遇到中文乱码问题解决方法
不用引其他js包 encodeURI方法是js底层有的方法 js方法 var url="<%=request.getContextPath()%>/laPlanForm/forUpdate4DistributeDepart.so?planId="+planIds+"&departName="+encodeURI(encodeURI(departName))+"&struId="+struId+"&batch=true"; var param=""; var myAjax=new Ajax.Request(url,{method:'post',parameters:param,onSucces…
2013-05-03 16:40 · JavaScript · 评论(0)
ZipFile(如何实现对文件和目录的压缩,解压缩?
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; public…
2013-03-22 21:20 · Java · 评论(0)
jsp或者java中获得(项目路径和项目中文件路径)问题
获取文件路径 String path=this.getClass.getClassLoader().getResource("").getPath().substring(1);//如:D:/workspaces/zemo/build/classes/ String path=path+fileName;//如:fileName="模板.doc";则结果为:D:/workspaces/zemo/build/classes/模板.doc 通过此路径就可以获得文件流 如:InputStream in = new BufferedInputStream(new FileInputStream(fi…
2013-03-21 21:33 · Java · 评论(0)