冠宇 的个人资料BC on earth照片日志列表更多 工具 帮助

日志


6月12日

利用百度作站内搜索

把下面的sjtu.edu.cn换成自己的网站就可以了,起始就是给输入搜索关键字加一个site:sjtu.edu.cn 的后缀,3x百度了。
<script>
function onon(){
var a=form1.word.value;
a=a+" "+"site:sjtu.edu.cn";
form1.word.value=a;
form1.submit();
return 1;
}
</script>
<form name=form1 action="http://www.baidu.com/baidu" target="_blank">
<table ><tr><td>
<input name=tn type=hidden value=baidu>
<input type=text name=word size=10>
<input type="button" onclick="return onon()" value="站内搜索">
</td></tr></table>
</form>
6月11日

smtp验证

用foxmail的交大邮箱账户给交大邮箱发信总是失败,出个警告(7)窗口,今天好好看了一下这个窗口的提示,到提示地址http://postgrey.schweikert.ch/help/sjtu.edu.cn.html看了一下,发现这么一句Make sure that you did turn on encryption and authentication for the SMTP server in your mail client,回来看foxmail设置里果然有一项“smtp需要验证”,选中,OK了。唉……
6月6日

div自动居中

自己做的页面中用到了div,position又设置为了absolute,页面在1024*768分辨率下是没问题的,但换个2048*1096就顶到左上角去了,怎么居中呢?研究了一下,找到种可行的方法。只有在原来基础上稍加改动就行,还是比较理想的。首先要定义两个style,设置好页面属性,然后就是给绝对位置的div外面套两层div,类似
=====================================
<html>
<body>
<head>
<style type="text/css">
     body {     
     background-repeat: repeat-x repeat-y;
     background-position: left top;
     text-align:center;
     }
   .container{
     margin-left:auto;
     margin-right:auto;
     width:738px;
    }
    .layer0{
     position: relative;
     width: 738px;
     height: 40px;     
    }
 </style>
  </head>
<body>

<div id="container" class="container">
<div id="layer0" class="layer0">
***********your code here****************
</div>
</div>

</body>
</html>
====================================
 

commons-email自动发信

自己搞了一下,主要参考了下面的转载,另外要注意的是要把commons-email.jar和mail.jar放到WEB-INF/lib目录下,否则可能出现noclassdef错误。
 
以下是转载:
commons-email是apache提供的一个开源的API,是对javamail的封装,因此在使用时要将javamail.jar加到class path中,主要包括SimpleEmail,MultiPartEmail,HtmlEmail,EmailAttachment四个类。
 
SimpleEmail:发送简单的email,不能添加附件
MultiPartEmail:文本邮件,可以添加多个附件
HtmlEmail:HTML格式邮件,同时具有MultiPartEmail类所有“功能”
EmailAttchment:附件类,可以添加本地资源,也可以指定网络上资源,在发送时自动将网络上资源下载发送。
 
发送基本文本格式邮件:
==============
SimpleEmail email = new SimpleEmail();
//smtp host
email.setHostName("mail.test.com");
//登陆邮件服务器的用户名和密码
email.setAuthentication("test","testpassword");
//接收人
email.addTo("jdoe@somewhere.org", "John Doe");
//发送人
email.setFrom("me@apache.org", "Me");
//标题
email.setSubject("Test message");
//邮件内容
email.setMsg("This is a simple test of commons-email");
//发送
email.send();
发送文本格式,带附件邮件:
==================
//附件,可以定义多个附件对象
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("e:\\1.pdf");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
//
MultiPartEmail email = new MultiPartEmail();
//smtp host
email.setHostName("mail.test.com");
//登陆邮件服务器的用户名和密码
email.setAuthentication("test","testpassword");
//接收人
email.addTo("jdoe@somewhere.org", "John Doe");
//发送人
email.setFrom("me@apache.org", "Me");
//标题
email.setSubject("Test message");
//邮件内容
email.setMsg("This is a simple test of commons-email");
//添加附件
email.attach(attachment);
//发送
email.send();
 
发送HTML格式带附件邮件:
=================
//附件,可以定义多个附件对象
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("e:\\1.pdf");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
//
HtmlEmail email = new HtmlEmail ();
//smtp host
email.setHostName("mail.test.com");
//登陆邮件服务器的用户名和密码
email.setAuthentication("test","testpassword");
//接收人
email.addTo("jdoe@somewhere.org", "John Doe");
//发送人
email.setFrom("me@apache.org", "Me");
//标题
email.setSubject("Test message");
//邮件内容
email.setHtmlMsg("<b>This is a simple test of commons-email</b>");
//添加附件
email.attach(attachment);
//发送
email.send();

跟随web3.0

Web3.0,网络以人为主,have a try