51.向文件中写内容
<%@ page import="java.io.*" %>
<%
String str = "print me";
//always give the path from root. This way it almost always works.
String nameOfTextFile = "/usr/anil/imp.txt";
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));
pw.println(str);
//clean up
pw.close();
}
catch(IOException e)
{
out.println(e.getMessage());
}
%>
52.先读文件再写文件
<%@ page language = "java" %>
<%@ page contentType = "text/html; charSet=gb2312" %>
<%@ page import ="java.util.*" %>
<%@ page import ="java.lang.*" %>
<%@ page import ="javax.servlet.*" %>
<%@ page import ="javax.servlet.jsp.*" %>
<%@ page import ="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
eryrytry
<%
int count=0;
FileInputStream fi =new FileInputStream ( "count.txt");
ObjectInputStream si= new ObjectInputStream (fi);
count =si.readInt();
count++;
out.print(count);
si.close();
FileOutputStream fo =new FileOutputStream ("count.txt");
ObjectOutputStream so= new ObjectOutputStream (fo);
so.writeInt(count);
so.close();
%>
53.直线型输入框
<INPUT name=Password size=10 type=password style="border-left-width: 0; border-right-width: 0;
border-top-width: 0; border-bottom-style: solid; border-bottom-width: 1; background-color: #9CEB9C">
54.可以将背景改为按钮性状,通过改变css改变属性
<td width="65" align="center" bgcolor="#E0E0E0" onmouseover=this.className='mouseoverbt';
onmouseout=this.className='mouseout';><a href="tm.asp?classid=76"><font
color="#000000">录音笔</font></a></td>
<style>
.mouseoverbt
{
background-image: url( http://www.yongle.com.cn/img/btbgw64h20y.gif);
background-repeat: no-repeat;
}
.mouseout
{
background-color: #E0E0E0;
}
</style>
55.同时按下CTRL和Q键
document.onkeydown=function()
{
if(event.ctrlKey&&event.keyCode==81)
{alert(1)}
}//
56.以下是一个完整的显示hint的代码,其思想是当鼠标停留是将div中的内容显示在鼠标出,当鼠标移出后在将该div隐
藏掉
---------------------------------------------------------------------------------------------------------
------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<style>
#hint{
width:198px;
border:1px solid #000000;
background:#99ff33;
position:absolute;
z-index:9;
padding:6px;
line-height:17px;
text-align:left;
top: 1520px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function showme()
{
var oSon=window.document.getElementById( "hint");
if (oSon==null) return;
with (oSon)
{
innerText=guoguo.value;
style.display= "block";
style.pixelLeft=window.event.clientX+window.document.body.scrollLeft+6;
style.pixelTop=window.event.clientY+window.document.body.scrollTop+9;
}
}
function hidme()
{
var oSon=window.document.getElementById( "hint");
if (oSon==null) return;
oSon.style.display= "none";
}
//-->
</SCRIPT>
<BODY>
<text id=guoguo value=ga>
<a href=# onmouseover=showme() onmouseout=hidme() onmousemove=showme() son=hint>dfdfd</a>
<div id=hint style="display:none"></div>
</BODY>
</HTML>
---------------------------------------------------------------------------------------------------------
------------
57.弹出窗口
方法一:<body onload="openwen()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwen()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:<a href="#" onclick="openwin()">打开一个窗口</a>
注意:使用的"#"是虚连接。
方法四:用一个按钮调用:<input type="button" onclick="openwin()" value="打开窗口"> 何时装载script
58.动态改变字体的大小
function doZoom(size)
{
document.getElementById('zoom').style.fontSize=size+'px'
}
function aa()
{
var newWin=window.open(url);
newWin.document.form1.text1.value=value1;
}改变弹出窗口上域的属性
opener.document.form2.text2.value=value2;改变父窗口的域的值
59.判断是何种浏览器
var name = navigator.appName;
if (name == "Microsoft Internet Explorer")
alert( "IE");
else if (name == "Netscape")
alert( "NS");//
60.vbsscript确定框
<script language="VBScript">
<!--
MsgBox "确定删除吗?", 4
//-->
</script>//
61.复制内容到剪切板
function JM_cc(bb)
{
var ob=eval( "document.form1."+bb);
ob.select();
js=ob.createTextRange();
js.execCommand( "Copy");
}//
62.java中建立数据库连接取数据
public void init()
{
String url= "jdbc:odbc:javadata";
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url, "sa","");//mssql database user SA and password
DatabaseMetaData dma=con.getMetaData();
System.out.println( "Connect to"+dma.getURL());
System.out.println( ";Driver "+dma.getDriverName());
System.out.println( ";Version "+dma.getDriverVersion());
System.out.println( "");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery( "select * from company.dbo.TB_NAME where number=1");//Sql
rs.next();
String dispresult=rs.getString( "name");
System.out.println(dispresult);// Instead,you can display it in Paint() or use AWT etc.
rs.close();
stmt.close();
con.close();
}
catch(SQLException ex)
{
System.out.println( "!!!SQL Exception !!!");
while(ex!=null)
{
System.out.println( "SQLState:"+ex.getSQLState());
System.out.println( "Message:"+ex.getMessage());
System.out.println( "Vendor:"+ex.getErrorCode());
ex=ex.getNextException();
System.out.println( "");
}
}
catch(java.lang.Exception ex)
{
ex.printStackTrace();
}
}//
63.最小化窗口
window.blur()//
64.文档的路径
document.URL//
65.定时执行某段程序
setTimeout("change_color()",600);
66.设置为主页
function makeHome(){
netscape.security.PrivilegeManager.enablePrivilege( "UniversalPreferencesWrite");
navigator.preference( "browser.startup.homepage", location.href);
}//
67.设置为收藏
function addFav(){
if(ie)
window.external.AddFavorite(location.href,'WWW.OGRISH.COM : GROTESQUE MOVIES AND PICTURES');
if(ns)
alert( "Thanks for the bookmark!\n\nNetscape users click OK then press CTRL-D");
}//
68.判断cookie是否可用
navigator.cookieEnabled;//
69.显示有模式的有页面的弹出窗口
function setbgcolor_onclick()
{
var color = showModalDialog( "/mailpage/compose/colorsel.html",0,"help=0");
if (color != null)
{
document.compose.bgcolor.value = color;
}
}//
70.截取小数点后两位
var a=3454545.4454545;
alert(a.toFixed(2));//
71.禁止选择页面上的文字来拷贝
<script>
function noEffect() {
with (event) {
returnValue = false;
cancelBubble = true;
}
return;
}
</script>
<body onselectstart="noEffect()" oncontextmenu="noEffect()">//
72.屏蔽右键菜单
oncontextmenu="event.returnValue = false"//
73.事件禁止起泡
event.cancelBubble = true//
74.禁止在输入框打开输入法
<input style="ime-mode: disabled">//
75.屏蔽汉字和空格
<input name="txt"><input type="submit" onClick="alert(!/[^ -}]|\s/.test(txt.value))">//
76.用javascript判断文件是否存在
function Exists(filespec)
{
if (filespec)
{
var fso;
fso = new ActiveXObject( "Scripting.FileSystemObject");
alert(fso.FileExists(filespec));
}
}
选择图片 <input type=file name=f1><p>
<input type="submit" onClick="Exists(f1.value)">//
77.获得当前的文本框选中的文字
<input onmouseup="alert(document.selection.createRange().text)" value=123>//
78.跳转至目标页面,同时不可返回
<a href="javascript:location.replace('http://www.sohu.com/')">sohu.com</a>//
79.获得当前的行是表格的第几行
<script>
function getrow(obj)
{
if(event.srcElement.tagName== "TD"){
curRow=event.srcElement.parentElement;
alert( "这是第"+(curRow.rowIndex+1)+"行");
}
}
</script>
<table border="1" width="100%" onclick=getrow(this)>
<tr>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
</tr>
<tr>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
</tr>
</table>//
80.删除表格某行,xx表示某行,下标从0开始计算
docume
没有合适的资源?快使用搜索试试~ 我知道了~
struts,spring,hibrenate三个框架的小例子
共111个文件
jar:25个
java:17个
class:17个
需积分: 9 13 下载量 200 浏览量
2008-12-29
18:34:44
上传
评论
收藏 7.57MB RAR 举报
温馨提示
struts,spring,hibrenate三个框架的小例子:包括增删改查 和文件上传
资源推荐
资源详情
资源评论
收起资源包目录
struts,spring,hibrenate三个框架的小例子 (111个子文件)
Dao.class 8KB
StudentAction.class 7KB
InfoAction.class 4KB
BaseAction.class 3KB
StuServicesImpl.class 3KB
HibernateDao.class 3KB
HibernateSessionFactory.class 3KB
FileUpload.class 2KB
StudentForm.class 2KB
Student.class 2KB
CharacterEncodingFilter.class 1KB
InfoServicesImpl.class 1KB
InfoForm.class 1KB
Info.class 902B
Service.class 552B
StuServices.class 466B
InfoService.class 323B
.classpath 548B
org.eclipse.wst.common.component 442B
Thumbs.db 17KB
hibernate-3.2.6.ga.jar 2.17MB
spring-1.2.7.jar 1.84MB
standard-1.0.2.jar 504KB
antlr-2.7.6.jar 433KB
mysql-connector-java-3.1.10-bin.jar 409KB
struts-core-1.3.8.jar 321KB
dom4j-1.6.1.jar 307KB
cglib-2.1_3.jar 276KB
struts-el-1.3.8.jar 258KB
struts-taglib-1.3.8.jar 246KB
commons-beanutils-1.7.0.jar 184KB
commons-collections-2.1.1.jar 171KB
commons-digester-1.8.jar 140KB
xml-apis-1.0.b2.jar 107KB
commons-dbcp-1.2.1.jar 105KB
commons-chain-1.1.jar 88KB
commons-io-1.2.jar 64KB
commons-fileupload-1.2.1.jar 56KB
commons-codec-1.3.jar 46KB
commons-pool-1.2.jar 41KB
commons-logging-1.0.4.jar 37KB
asm-1.5.3.jar 26KB
jstl-1.1.2.jar 20KB
asm-attrs-1.5.3.jar 16KB
jta-1.0.1B.jar 13KB
Dao.java 8KB
StudentAction.java 6KB
HibernateDao.java 4KB
HibernateSessionFactory.java 3KB
InfoAction.java 2KB
BaseAction.java 2KB
StuServicesImpl.java 2KB
StudentForm.java 1KB
FileUpload.java 1KB
CharacterEncodingFilter.java 1019B
Student.java 1004B
InfoServicesImpl.java 719B
InfoForm.java 617B
Info.java 493B
StuServices.java 407B
InfoService.java 257B
Service.java 232B
1 (31).jpg 257KB
1600_011.jpg 151KB
7fdsgd.jpg 61KB
1 (138).jpg 58KB
0001779081.jpg 18KB
infos.js 606B
listStus.jsp 3KB
index.jsp 2KB
updateStu.jsp 2KB
addStu.jsp 1KB
listInfo.jsp 800B
addInfo.jsp 791B
OneInfo.jsp 665B
success.jsp 520B
success.jsp 510B
MANIFEST.MF 39B
org.eclipse.jdt.core.prefs 330B
org.eclipse.jst.common.project.facet.core.prefs 288B
org.eclipse.core.resources.prefs 170B
.project 852B
student.sql 2KB
student.sql 2KB
info.sql 1KB
struts-html.tld 352KB
struts-nested.tld 163KB
struts-logic.tld 74KB
struts-bean.tld 45KB
fmt.tld 19KB
c.tld 16KB
fmt-1_0.tld 12KB
fmt-1_0-rt.tld 11KB
c-1_0.tld 11KB
c-1_0-rt.tld 11KB
math.tld 832B
jsjs.txt 14KB
文件下载.txt 705B
bb.txt 94B
aaaaabb.txt 85B
共 111 条
- 1
- 2
资源评论
fanyanxia
- 粉丝: 1
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功