Skip to content

Instantly share code, notes, and snippets.

View wdfx100's full-sized avatar

wangxu wdfx100

View GitHub Profile
@wdfx100
wdfx100 / 第一个code
Created December 6, 2012 03:55
数字取反
//数字取反
java.util.Scanner input=new java.util.Scanner(System.in);
System.out.println("请输入要取反的数字:");
int i=input.nextInt();
do{
int j=i%10;
System.out.print(j);
i=i/10;
if(i<10){
System.out.print(i);
@wdfx100
wdfx100 / code
Created December 6, 2012 03:56
猜数字
input=new java.util.Scanner(System.in);
random=new java.util.Random();
//取随机数
int num=random.nextInt(100);
System.out.println(num);
boolean flag=true;
int count=0;
while(flag){
System.out.println("请输入你的数字:");
int i=input.nextInt();
@wdfx100
wdfx100 / java
Created December 6, 2012 12:44
冒泡排序
int temp;
for(int i=0;i<num.length-1;i++){
for(int j=0;j<num.length-i-1;j++){
if(num[j]>num[j+1]){
temp=num[j];//大的先拿出来
num[j]=num[j+1];//小的往前移
num[j+1]=temp;//大的往后移
}
}
}
@wdfx100
wdfx100 / gist:5231091
Created March 24, 2013 08:34
Chrome调试js出现Uncaught SyntaxError: Unexpected identifier
chrome下运行编写的javascript代码时,在工具javascript控制台下有时会出现“Uncaught SyntaxError: Unexpected identifier ”的报错,经过我反复查看代码最后得出,原来是代码中缺少一个“,”(英文逗号)。
后经在网上查阅,也有文章指出,如果该异常出现在define里多半是因为你在该行的上一行缺少了逗号。
原来如此简单!
在js中出现下面的错误:
Uncaught SyntaxError: Unexpected identifier可能的原因是:
@wdfx100
wdfx100 / gist:5267970
Created March 29, 2013 00:44
Tomcat设置虚拟目录,及修改本地主机
一、三种设置虚拟目录的方式
Tomcat设置 /conf/server.xml
• 修改端口号
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
@wdfx100
wdfx100 / js
Created March 29, 2013 00:53
IE与chrome及其他跨浏览器的时间对象对象eventUtil.js
var eventUtil={
addHandler:function(element,type,handler){
if(element.addEventListener){
element.addEventListener(type,handler,false);
}else if(element.attachEvent){
element.attachEvent("on"+type,handler);
}else{
element["on"+type]=handler;
@wdfx100
wdfx100 / database
Created March 29, 2013 05:22
DBhelp.java
public class DBhelp<T>{
final String DRIVER="com.mysql.jdbc.Driver";
final String URL="jdbc:mysql://127.0.0.1:3306/bookSystem";
final String USERNAME="root";
final String PASSWORD="123";
/**
* 获取数据库连接对象
@wdfx100
wdfx100 / 数据库
Last active December 16, 2015 05:49
数据库连接池
//jar:commons-dbcp-1.4
//依赖的jar:commons-pool-1.5.6
//第一种//
private static BasicDataSource bd=null;
static{
bd = new BasicDataSource();
bd.setDriverClassName(DIRVER);
bd.setUrl(URL);
bd.setUsername(NAME);
bd.setPassword(PASSWORD);
@wdfx100
wdfx100 / EmailUtil
Last active December 16, 2015 06:08
发送电子邮件
//jar:commons-email-1.2
//1.5的javaee.jar下的mail文件删除,添加1.4的mail.jar
//1、commons-email发送普通文本邮件
public static void sendSimpleEmail(String toEmailAddress,String subject,String msg){
Email email = new SimpleEmail();
email.setHostName("smtp.163.com");//发信件的邮件服务器
email.setAuthentication("wdfx100", "**********");//设置身份验证:用户名和密码
email.setCharset("UTF-8");
@wdfx100
wdfx100 / upload.java
Last active December 16, 2015 06:59
#文件上传#
//commons.apache.org 下的一个组件 upload
//jar:commons-fileupload-1.2.2.jar,依赖jar:commons-io-1.4.jar
<form action="fileUpload" method="post" enctype="multipart/form-data">
文件描述:<input type="text" name="filedesc"><br/>
<input type="file" name="myfile"><br/>
<input type="submit" value="提交"/>
</form>
if(ServletFileUpload.isMultipartContent(request)){//获取请求的方式改变