ITeye博客

2011 年文章归档

共 17 篇文章

hibernate Criteria查询多对多(Set集合)条件筛选

查询用户userStatus等于1且他的角色Level等于3的用户 PO public class UserPO implements java.io.Serializable { /** 用户唯一标识ID */ private String id; /** 状态(在用1停用0) */ private String userStatus; private Set roles = new HashSet(); ........ } public class RolePOimplements java.io.Serializable { /** 角色唯一标识ID */ private Strin…

2011-08-07 16:03 · hibernate

javascript判断上传图片文件类型(后缀名)

1、根本是正则表达式,不存在浏览器问题 /* * 判断图片类型 * * @param ths * type="file"的javascript对象 * @return true-符合要求,false-不符合 */ function checkImgType(ths){ if (ths.value == "") { alert("请上传图片"); return false; } else { if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(ths.value)) { alert("图片类型必须是.gif,jpeg,jpg,png中的一种"); ths…

2011-08-07 15:19 · JavaScript

JSP 无刷新文件上传 类似AJAX

ajax 是无法实现上传文件的 , ajax与后台通信都是通过传递字符串 -- index.html <form action="upload.jsp" id="form1" name="form1" encType="multipart/form-data" method="post" target="hidden_frame" > <input type="file" id="file" name="file" style="width:450"> <input type="submit" value="上传文件"><span id="msg"></span> <br> <font co…

2011-08-07 14:58 · 服务器端代码块 · java 文件上传

hibernate Restrictions 用法 查询

import hibernate classes import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; DetachedCriteria criteria = DetachedCriteria.forClass(UserPO.class); // 按照用户名排序 -- 升序 criteria.addOr…

2011-08-07 11:54 · hibernate

为window系统桌面鼠标右键增加Delete SVN Folders菜单,SVN断开资源库

后缀名: .reg 内容: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN] @="Delete SVN Folders" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command] @="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO …

2011-08-04 15:52 · 工具

eclipse的默认(打开)编辑器的更改

eclipse / MyEclipse JSP默认打开方式是 MyEclipse Visual JSP Designer 它包含了Preview界面所以很慢,而我们如果只需要看代码的话就可以在打开JSP文件时 右键JSP文件 --> Open With --> MyEclipse JSP Editor 但是这样很繁琐,所以要修改eclipse的默认打开(双击)方式 window --> preferences --> General --> Editors --> File Associations 选择相应的文件后缀名后下面会出现可选打开方式. 选择自己想要的点击右边" Default "…

2011-08-04 15:49 · 工具

JAVA获得图片像素

package cn.net.comsys.sso; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.*; public class Test { public static void main(String args[]) { File file = new File("a.bmp"); BufferedImage bi = null; try { bi = ImageIO.read(file); } catch (Exception e) { e.printStackTra…

2011-08-03 14:33 · 服务器端代码块

单独刷新验证码图片

// 点击验证码图片便重新获取验证码 $("#img_login_captcha").click(function() { this.src = "captcha?random=" + Math.random(); }); 随机数追加到请求参数中

2011-07-30 16:31 · JavaScript · 服务器端代码块

JavaScript常用

正则表达式 var 1 = /^([a-zA-Z0-9]|[_]){6,18}$/; //6~18位字符数字下划线 var 2 = /^([a-zA-Z0-9]){4}$/; 比较正则表达式 value.match(reg) == null 刷新当前页面 window.location.reload(); confirm if (window.confirm("确认?")) { } else { return; } 随机数 Math.random();// 0~1的随机数

2011-07-30 16:29 · JavaScript

javascript当前时间

var date = new Date(); var d = ""; var t = date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日" + date.getHours() + "时" + date.getMinutes() + "分";//date.getSeconds() + "秒" var nowtime = date.getHours() + "时" + date.getMinutes() + "分"; if (date.getHours() < 8) { d = "早晨"; } …

2011-07-30 16:26 · JavaScript

Jquery常用

修改样式 if (now == null || now == "" || now == "null") { // 注意字符串"null" now = "opt_11"; } $("#"+now).css("display", ""); $("#img"+now).attr("src","images/index/close.gif"); $("#img"+now).attr("alt","收起"); 1、div // 设值 $("#div_id").text(''); // 隐藏 $("#div_id").hide(); 2、input // this this.value // 取值 //…

2011-07-30 16:24 · JQuery

java利用fw.qq获得IP及地址

1、前端JS获取 <script type="text/javascript" src="http://fw.qq.com/ipaddress"></script> <script type="text/javascript"> document.write(IPData.join(' ')); </script> 或者 <script type="text/javascript" src="http://fw.qq.com/ipaddress"></script> <script type="text/javascript"> document.write(IPData[0]+','+IP…

2011-07-30 15:01 · 服务器端代码块

JSP上传文件Servlet(Apache fileUpload)同时text文本

以Apache组织的commons项目中的FileUpload项目做为jsp的文件上传组件。 在开始之前你要准备以下几个东西: 1. commons-FileUpload 包 下载地址: http://commons.apache.org/fileupload/ 2. commons-IO 包 下载地址: http://commons.apache.org/io/ 3. Commons-BeanUtils 包 下载地址: http://commons.apache.org/beanutils/ 准备工作完成就开始了: 1、新建一个WEB项目upload; 2、把下载好了的jar包复制到项目的…

2011-06-30 17:00 · 服务器端代码块 · java 文件上传

JQuery入门 -- 01 -- API

1、HelloWord $(document).ready(function(){ alert("Hello Word!!!"); }); //或者更简单点: $(function(){ alert("Hello Word!!!"); }); 2、与DOM对象的转换: //Dom转jQuery var dom = document.getElementById("id"); var jq = $(dom); alert(jq.html()); //jQuery转Dom var jq = $("#id"); var dom = $(jq)[0];//是数组,判断的话:$(jq).length>…

2011-03-21 17:27 · JQuery

dwr入门 -- 03 -- 结合Spring

1、WEB工程+Spring的jar包+DWR.jar 2、web.xml,配置spring和dwr: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/w…

2011-03-21 11:54 · AJAX

dwr入门 -- 02 -- HelloWord解释&&使用javabean

1、在web.xml添加一段代码,解决上一篇第一访问时的错:DefaultContainer can't find a classes。修改结果如下: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java…

2011-03-21 09:55 · AJAX

dwr入门 -- 01 -- Hello Word

dwr: http://directwebremoting.org/dwr/index.html 1、新建WEB项目,把dwr.jar放在WEB-INF/lib下. 2、修改web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/n…

2011-03-18 15:08 · AJAX