假如你的笔记本需要在家里和公司频繁地进行IP地址切换,是不是很烦?而网上大量的切换工具对Win7均无效,怎么办?请不要担心,自己DIY一个批处理文件就行了。
注意,以下是针对IPv4进行的修改。
另外,安装了360可能会有风险提醒,请大家不要担心,放心点击通过,此代码毫无风险,童叟无欺,尽可安全使用。
首先,打开记事本,新建一个"IP切换.txt",内容如下,
最后,把文件名改为"IP切换.bat"就大功告成了。
@echo off
rem //设置变量本地连接, 根据你的需要更改
set Nic="本地连接 3"
rem //可以根据你的需要更改
set Addr=192.168.1.11
set Mask=255.255.255.0
set Gway=192.168.1.1
set Dns=192.168.1.1
set Addr2=10.32.66.34
set Mask2=255.255.255.192
set Gway2=10.32.66.62
set Dns1=202.107.196.144
set Dns2=202.101.172.46
rem //以上对应分别是IP地址、子网掩码、网关、首选DNS、备用DNS ,自己根据情况修改
rem //家里的DNS和公司一样则可以用以上代码,不一样可能需要稍作修改
echo ↗Design by 鲁胜迪,龙腾虎跃↖
echo ★ 1 设置为公司IP ★
echo ★ 2 设置为***综合楼IP★
echo ★ 3 设置为动态IP ★
echo ★ 4 退出 ★
echo ●●●请选择项目回车●●●
set /p answer=
if %answer%==1 goto 1
if %answer%==2 goto 2
if %answer%==3 goto 3
if %answer%==4 goto 4
:1
echo 正在进行静态公司IP 设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %Addr%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic% source=static addr=%Addr% mask=%Mask% gateway=%Gway% gwmetric=0 >nul
echo. 首选 DNS = %Dns%
netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns% register=PRIMARY >nul
echo. 备用 DNS = %Dns%
netsh interface ipv4 add dns name=%Nic% addr=%Dns% index=2 >nul
echo ----
echo 全部设置完成!
pause
goto end
:2
echo 正在进行静态萧山区政府综合楼IP设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr2%
echo. 子网掩码 = %Mask2%
netsh interface ipv4 set address name=%Nic% source=static addr=%addr2% mask=%Mask2% gateway=%Gway2% gwmetric=0 >nul
echo. 首选 DNS = %Dns1%
netsh interface ipv4 set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo. 备用 DNS = %Dns2%
netsh interface ipv4 add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ----
echo 全部设置完成!
pause
goto end
:3
echo 正在进行动态IP设置,请稍等...
echo. IP 地址正在从DHCP自动获取...
netsh interface ip set address %Nic% dhcp
echo. DNS地址正在从DHCP自动获取...
netsh interface ip set dns %Nic% dhcp
echo ----
echo 全部设置完成!
pause
:4
echo bye!
goto end
我使用的是JSF+Spring+Hibernate,在实现文件上传时遇到了这个问题,每次上传一个文件就会出现一次这个警告,但是似乎并不影响文件的上传,文件还是可以保存到数据库中相应的表中的。
想解决这个问题,但不知道从何下手个,希望能有高手指点一下。
Hibernate: insert into WTCX.T_FILE (FILENAME, CONTENT, FILESUFFIX, FILEID) values (?, ?, ?, ?)
2008-09-19 15:56:28,125 ERROR [org.springframework.jdbc.support.lob.OracleLobHandler] - Could not free Oracle LOB
java.sql.SQLException: 必须登录到服务器
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
at oracle.jdbc.ttc7.TTC7Protocol.assertLoggedIn(TTC7Protocol.java:2196)
at oracle.jdbc.ttc7.TTC7Protocol.freeTemporaryLob(TTC7Protocol.java:3233)
at oracle.sql.LobDBAccessImpl.freeTemporary(LobDBAccessImpl.java:377)
at oracle.sql.BLOB.freeTemporary(BLOB.java:842)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.close(OracleLobHandler.java:412)
at org.springframework.jdbc.support.lob.SpringLobCreatorSynchronization.afterCompletion(SpringLobCreatorSynchronization.java:76)
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:133)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:904)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:879)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:707)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy22.insertFile(Unknown Source)
at cn.com.hd.zzjgManage.web.UploadBean.saveAction(UploadBean.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
at javax.faces.component.UICommand.broadcast(UICommand.java:106)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.com.hd.common.filter.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.com.hd.common.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
共计以下4个文件 点击“下载”
login.html
welcome.html
cookie.js
common.js
login.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>login</title>
<script type="text/javascript" src="cookie.js"></script>
<script type="text/javascript" src="common.js"></script>
</head>
<body>
<form action="">
<p>
<span>UserName:</span>
<input id="userName" type="text" value=""/></p>
<p>
<span>Password:</span>
<input id="password" type="password" value=""/></p>
<p>
<span style="font-size:12px; color:blue;">记住密码</span>
<input id="saveCookie" type="checkbox" value="" /></p>
<p>
<input id="submit" type="button" value="GO" />
</p>
</form>
</body>
</html>
welcome.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>welcome</title>
</head>
<body>
<h1>Welcome!</h1>
<a href="login.html">点击返回登陆框</a>
</body>
</html>
cookie.js
//新建cookie。
//hours为空字符串时,cookie的生存期至浏览器会话结束。hours为数字0时,建立的是一个失效的cookie,这个cookie会覆盖已经建立过的同名、同path的cookie(如果这个cookie存在)。
function setCookie(name,value,hours,path){
var name = escape(name);
var value = escape(value);
var expires = new Date();
expires.setTime(expires.getTime() + hours*3600000);
path = path == "" ? "" : ";path=" + path;
_expires = (typeof hours) == "string" ? "" : ";expires=" + expires.toUTCString();
document.cookie = name + "=" + value + _expires + path;
}
//获取cookie值
function getCookieValue(name){
var name = escape(name);
//读cookie属性,这将返回文档的所有cookie
var allcookies = document.cookie;
//查找名为name的cookie的开始位置
name += "=";
var pos = allcookies.indexOf(name);
//如果找到了具有该名字的cookie,那么提取并使用它的值
if (pos != -1){ //如果pos值为-1则说明搜索"version="失败
var start = pos + name.length; //cookie值开始的位置
var end = allcookies.indexOf(";",start); //从cookie值开始的位置起搜索第一个";"的位置,即cookie值结尾的位置
if (end == -1) end = allcookies.length; //如果end值为-1说明cookie列表里只有一个cookie
var value = allcookies.substring(start,end); //提取cookie的值
return (value); //对它解码
}
else return ""; //搜索失败,返回空字符串
}
//删除cookie
function deleteCookie(name,path){
var name = escape(name);
var expires = new Date(0);
path = path == "" ? "" : ";path=" + path;
document.cookie = name + "="+ ";expires=" + expires.toUTCString() + path;
}
common.js
function $(objStr){return document.getElementById(objStr);}
window.onload = function(){
//分析cookie值,显示上次的登陆信息
var userNameValue = getCookieValue("userName");
$("userName").value = userNameValue;
var passwordValue = getCookieValue("password");
$("password").value = passwordValue;
//写入点击事件
$("submit").onclick = function()
{
var userNameValue = $("userName").value;
var passwordValue = $("password").value;
//服务器验证(模拟)
var isAdmin = userNameValue == "admin" && passwordValue =="123456";
var isUserA = userNameValue == "userA" && passwordValue =="userA";
var isMatched = isAdmin || isUserA;
if(isMatched){
if( $("saveCookie").checked){
setCookie("userName",$("userName").value,24,"/");
setCookie("password",$("password").value,24,"/");
}
alert("登陆成功,欢迎你," + userNameValue + "!");
self.location.replace("welcome.html");
}
else alert("用户名或密码错误,请重新输入!");
}
}