`
收藏列表
标题 标签 来源
计算价格代码 javascript
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>

        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script  type="text/javascript" language="javascript">
	function jisuan(){
		var distance=document.getElementById("distance").value;
		var time=document.getElementById("time").value;
		var carType=document.getElementById("carType").value;
		var price=0;
		
		if("1"==carType){
			price=time*0.6;
			price=price+10;
		if(distance<30){
			price=price+distance*3
			}
			else{
				price=price+90+(distance-30)*4.2;
				}
			}
			if("2"==carType){
			price=time*0.4;
			price=price+8;
		if(distance<30){
			price=price+distance*2
			}
			else{
				price=price+60+(distance-30)*3;
				}
			}
			document.getElementById("msg").innerHTML=price;
		}
	
	</script>
    </head>

    <body>
			<input id="distance" name="distance"/><br/>
			<input id="time" name="time"/>
			<select id="carType" name="carType">
				<option value="1"></option>
  			<option value="2"></option>
				</select><br/>
				<input type="button"  value="" onclick="jisuan()"/>
				<h2 id="msg"></h2>
    </body>
</html>
判断字符串是否全部为数字 正则表达式
Pattern pattern = Pattern.compile("[0-9]+");
		Matcher isNum = pattern.matcher(str);
		if (!isNum.matches()) {
			return false;
		}
		return true;
替换jsp文件中的特定字符串 jsp
package test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream; //import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
//import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ChangeFile {
	static int i = 100;
	static int j=0;
	public static void main(String[] argv) {
		try {
			getDir("E:\\ESB_CODE\\xtsp_cxtj\\WebRoot\\jsp");
			System.out.println("修改的文件个数为"+(i-100));
			System.out.println("包含的cookieId的文件个数为"+j);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void changeFile(String strPath) throws Exception {
		try {
			FileInputStream stream = new FileInputStream(strPath);
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(stream, "UTF-8"));
			StringBuffer strBuf = new StringBuffer();
			
			for (String tmp = null; (tmp = bufferedReader.readLine()) != null; tmp = null) {
				// 在这里做替换操作
				//判断该文件中有没有cookieId
				
				strBuf.append(tmp+"\r\n");
			}
			bufferedReader.close();
			if(strBuf.toString().indexOf("cookieId")!=-1){
				j++;
				System.out.println("该文件中包含cookieId,文件路径为"+strPath);
				
			}
			else{
				if (strBuf.toString().indexOf("<ecity:grid") != -1) {
				i++;
//				 PrintWriter printWriter = new PrintWriter(strPath);
//				 printWriter.write(strBuf.toString().replace("<ecity:grid",
//							"<ecity:grid cookieId=\"grid" + i + "\""));
//				 printWriter.flush();
//				 printWriter.close();
				 Writer out = null;
				  try {
				   out = new BufferedWriter(new OutputStreamWriter(
				     new FileOutputStream(new File(strPath)), "UTF-8"));
				   out.write(strBuf.toString().replace("<ecity:grid",
							"<ecity:grid cookieId=\"grid" + i + "\""));
				   out.flush();
				  } catch (UnsupportedEncodingException e) {
				  } catch (IOException e) {
				  } finally {
				   if (out != null) {
				    try {
				     out.close();
				    } catch (IOException e) {
				    }
				   }

			}
				}
				
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	public static void getDir(String strPath) throws Exception {
		try {
			File f = new File(strPath);
			if (f.isDirectory()) {
				File[] fList = f.listFiles();
				for (int j = 0; j < fList.length; j++) {
					if (fList[j].isDirectory()) {
						getDir(fList[j].getPath()); // 在getDir函数里面又调用了getDir函数本身
					}
				}
				for (int j = 0; j < fList.length; j++) {

					if (fList[j].isFile()) {
						String name = fList[j].getName();
						String[] arr = name.split("[.]");
						String type = "." + arr[arr.length - 1];// 取出文件后缀名
						if(type.equalsIgnoreCase(".jsp")){
							changeFile(fList[j].getPath());
						}
					
					}

				}
			}
		} catch (Exception e) {
			System.out.println("Error: " + e);
		}

	}
	
}
DB2—alter追加/删除/重置column操作整理 db2 alter追加/删除/重置column操作整理
1.添加字段

alter table 表名称 add 字段名称 类型

Demo:

 alter table table_name  add  column_test VARCHAR(50); 
2. 更改字段类型

alter table 表名称 alter column 字段名 set data type 类型

Demo:

 alter table table_name alter column column_test set data type VARCHAR(3); 
注意: 更改字段类型是有操作限制的. 将字段改为比之前类型长度大的可以,如果要改小,必须先drop掉原来的column,然后再重新添加.

例如我要将一个Varchar(50)的column改为Varchar(30) ,这样采用以上的sql是不能成功的. 另外改为不同的类型,也需要先drop掉column.

3.去掉字段

alter table 表名称 drop column 字段名

Demo:

 alter table table_name drop column column_test; 
注意:drop掉字段之后,可能会导致表查询/插入操作不能执行,需要执行一下reorg命令才可以.

reorg table table_name;

4.为字段添加默认值

alter table 表名称 alter column 字段名 set default 值

Demo:

 alter table table_name alter column column_test set default  'value'; 
5. 添加带默认值的字段

Demo:

 alter table table_name add column column_test vachar(20) not null with default  'value'; 
6. 设置字段默认时间为当前时间

Demo:

 alter table table_name alter column column_test set default  current date; 
spring quartz 技术
	<bean id="prosjblts" class="this claaa path"></bean>	
	
	<!--  定义表格版本自动启用定时器  -->
	<bean id="Job" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject">
			<ref local="prosjblts" />
		</property>
		<property name="targetMethod">
			<!--  要执行的方法名称  -->
			<value>updateJdsjblts</value>
		</property>
	</bean>
	<!--定义触发的时间-->
	<bean id="cron"	class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="Job" />
		</property>
		<property name="cronExpression">
			<value>0 3 2 * * ?</value>
		</property>
	</bean>
	<!--  管理触发器  -->
	<bean autowire="no"
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref local="cron" />
			</list>
		</property>
	</bean>
Window.parent 和window.opener 的区别 window.parent, window.opener, 页面加载readystate的五种状态
Window.parent  和window.opener 的区别
Window.parent   弹窗打开的页面
window.opener 是指该页面的父页面,比如点击该页面链接打开的页面,该页面就为父页面


脚本
.用document.onreadystatechange的方法来监听状态改变, 

然后用document.readyState == “complete”判断是否加载完成 
代码如下: 
document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法. 
function subSomething() 
{ 
if(document.readyState == “complete”) //当页面加载状态 

myform.submit(); //表单提交 
} 

页面加载readyState的五种状态 

原文如下: 

0: (Uninitialized) the send( ) method has not yet been invoked. 
1: (Loading) the send( ) method has been invoked, request in progress. 
2: (Loaded) the send( ) method has completed, entire response received. 
3: (Interactive) the response is being parsed. 
4: (Completed) the response has been parsed, is ready for harvesting. 

翻译成中文为: 

0 - (未初始化)还没有调用send()方法 
1 - (载入)已调用send()方法,正在发送请求 
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容 
3 - (交互)正在解析响应内容 
4 - (完成)响应内容解析完成,可以在客户端调用了
Jsp 页面获取list的长度 jsp, list的长度
Jsp 页面获取list的长度
在jsp页面中不能通过${list .size }取列表长度,而是 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <c:out value="${fn:length(list )}"></c:out>
以指定编码读取文件
String path="D:\\demo.txt";
FileInputStream stream=new FileInputStream(path);
BufferedReader reader=new BufferedReader(new InputStreamReader(stream,"UTF-8"));
Global site tag (gtag.js) - Google Analytics