這里所說的不是驅(qū)動(dòng)對(duì)象,而是這個(gè)內(nèi)核模塊在內(nèi)核內(nèi)存空間中的地址。這是一個(gè)常用的技巧:在驅(qū)動(dòng)對(duì)象中DriverStart域和DriverSize域分別記載著這個(gè)驅(qū)動(dòng)對(duì)象所代表的內(nèi)核模塊在內(nèi)核空間中的開始地址和大小。
error LNK2019: unresolved external symbol _RtlStringVPrintfWorkerW@20 referenced in function _RtlStringCchPrintfW
error LNK2019: unresolved external symbol _RtlStringValidateDestW@12 referenced in function _RtlStringCchPrintfW
sources文件加入庫(kù)文件
TARGETLIBS= $(DDK_LIB_PATH)\ntstrsafe.lib
1>避免創(chuàng)建不必要的對(duì)象
2>如果方法用不到成員變量,可以把方法聲明為static,性能會(huì)提高15%到20%
3>避免使用getters/setters存取Field,可以把Field聲明為public,直接訪問
4>static的變量如果不需要修改,應(yīng)使用static final 修飾符定義為常量
5>使用增強(qiáng)for循環(huán)語(yǔ)法——for(:)
6>私有內(nèi)布類要訪問外部類的Field或方法,可以把外部類的Field或方法聲明為包訪問權(quán)限
7>合理使用浮點(diǎn)數(shù),浮點(diǎn)數(shù)比整型慢兩倍
這大概是由xml文件中的編碼規(guī)則決定要這么變換。
在xml文件中有以下幾類字符要進(jìn)行轉(zhuǎn)義替換:
<
|
<
|
小于號(hào)
|
>
|
>
|
大于號(hào)
|
&
|
&
|
和
|
'
|
'
|
單引號(hào)
|
"
|
"
|
雙引號(hào)
|
(function(){
if(!/*@cc_on!@*/0)
return;
var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;
while(i--){document.createElement(e[i])}
})()
//然后在head中引入該js
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
.
.
.
//改變狀態(tài)
this.addEventListener(MouseEvent.DOUBLE_CLICK,changeImg);
.
.
.
//改變
public function changeImg():void {
arguments; //如果方法沒有參數(shù),則必須在方法中添加這個(gè)聲明
if(this.source == img0) {
this.source = img1;
} else {
this.source = img0;
}
}
posted @
2012-04-15 12:20 aya000 閱讀(1462) |
評(píng)論 (0) |
編輯 收藏
請(qǐng)求登錄人人網(wǎng)比較麻煩,需要記住cookie,尤其是這句代碼,
httpContext.setAttribute(ClientContext.COOKIE_STORE,httpClient.getParams().getParameter("CookieStore"));試了很多遍才找到httpClient.getParams().getParameter("CookieStore"))。
主要代碼如下:
package com.koyo.downloadphoto.service.impl;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.tags.ImageTag;
import org.htmlparser.tags.LinkTag;
import org.htmlparser.tags.Span;
import org.htmlparser.util.NodeList;
import com.koyo.downloadphoto.service.Spider;
import com.koyo.downloadphoto.utils.HttpUtils;
import com.koyo.downloadphoto.utils.ParseUtils;
public class SpiderForRenRen extends Spider {
private Logger logger = Logger.getLogger(SpiderForRenRen.class);
@Override
public void execute() {
try {
String url = " + "/album/relatives";
// ===================請(qǐng)求登錄======================================================
HttpPost post = new HttpPost(" // 添加POST參數(shù)
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("email", loginName));
nvps.add(new BasicNameValuePair("password", loginPassword));
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
HttpResponse response = httpClient.execute(post, httpContext);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream is = entity.getContent();
// 使用響應(yīng)中的編碼來(lái)解釋響應(yīng)的內(nèi)容
String html1 = IOUtils.toString(is);
LinkTag linkTag1 = ParseUtils.parseTag(html1, LinkTag.class);
String url1 = linkTag1.getLink();
HttpGet get = new HttpGet(url1);
response = httpClient.execute(get, httpContext);
// 保存cookie
httpContext.setAttribute(ClientContext.COOKIE_STORE, httpClient
.getParams().getParameter("CookieStore"));
EntityUtils.consume(response.getEntity());
System.out.println("賬號(hào):" + loginName);
System.out.println("密碼:" + loginPassword);
}
// ===================獲取相冊(cè)頁(yè)面信息===================================================
// 根據(jù)URL地址,獲取網(wǎng)頁(yè)內(nèi)容
String html = HttpUtils.getHtml(httpClient, httpContext, url);
if (html == null) {
logger.error("無(wú)法獲取【" + url + "】網(wǎng)址的內(nèi)容");
throw new RuntimeException("無(wú)法獲取【" + url + "】網(wǎng)址的內(nèi)容");
}
//獲取好友名
Parser parser = new Parser();
parser.setInputHTML(html);
AndFilter andFilter = new AndFilter(new TagNameFilter("ul"), new HasAttributeFilter("class", "nav-tabs"));
NodeList nodes = parser.parse(andFilter);
String tempString = nodes.toHtml();
LinkTag tempTag = ParseUtils.parseTag(tempString, LinkTag.class);
String tempName = tempTag.getLinkText();
// String friendName = tempName.substring(tempName.indexOf("\n")+1,tempName.lastIndexOf("\n"));
String friendName = tempName.trim();
//獲取相冊(cè)名
String albumName;
List<LinkTag> linkTags = ParseUtils.parseTags(html, LinkTag.class,
"class", "album-cover");
List<Span> spans = ParseUtils.parseTags(html, Span.class,"class","album-name");
if (linkTags != null) {
for (int i=0; i<linkTags.size(); i++) {
tempName = spans.get(i).getStringText();
//由于頭像相冊(cè)前還有一個(gè)<span class="userhead"/> 故不能使用tempName.trim()
albumName = tempName.substring(tempName.lastIndexOf("\n")+1);
url = linkTags.get(i).getLink();
// 根據(jù)URL地址,獲取網(wǎng)頁(yè)內(nèi)容
html = HttpUtils.getHtml(httpClient, httpContext, url);
if (html == null) {
logger.error("無(wú)法獲取【" + url + "】網(wǎng)址的內(nèi)容");
throw new RuntimeException("無(wú)法獲取【" + url + "】網(wǎng)址的內(nèi)容");
}
List<LinkTag> linkTags2 = ParseUtils.parseTags(html,
LinkTag.class, "class", "picture");
if (linkTags2 != null) {
for (LinkTag linkTag2 : linkTags2) {
url = linkTag2.getLink();
// 根據(jù)URL地址,獲取網(wǎng)頁(yè)內(nèi)容
html = HttpUtils.getHtml(httpClient, httpContext,
url);
if (html == null) {
logger.error("無(wú)法獲取【" + url + "】網(wǎng)址的內(nèi)容");
throw new RuntimeException("無(wú)法獲取【" + url
+ "】網(wǎng)址的內(nèi)容");
}
// 網(wǎng)頁(yè)中所包含的圖片,并下載到upload目錄,然后創(chuàng)建Attachment對(duì)象
ImageTag imageTag = ParseUtils.parseTag(html,
ImageTag.class, "id", "photo");
if (imageTag != null) {
// 得到圖片所在的路徑目錄
// String baseUrl = url.substring(0,
// url.lastIndexOf("/") + 1);
// 這個(gè)是<img>標(biāo)簽中的src的值
String imageUrl = imageTag.getImageURL();
String photoName = imageUrl.substring(imageUrl
.lastIndexOf("/"));
// 圖片的絕對(duì)路徑
// String absoluteUrl = baseUrl + imageUrl;
// : "文章標(biāo)題/xxx.jpg"
String imageName = friendName + "/" +albumName + photoName;
// 把圖片保存到upload目錄
// 首先確定,保存到本地的圖片的路徑
String imageLocalFile = "D:/PhotosForRenRen/"
+ imageName;
// 如果圖片已經(jīng)被下載到本地,則不再下載
if (!new File(imageLocalFile).exists()) {
// 下載圖片的信息
byte[] image = HttpUtils.getImage(
httpClient, httpContext, imageUrl);
// 直接使用new
// FileOutputStream(imageLocalFile)這種方式,創(chuàng)建一個(gè)
// 文件輸出流,存在的問題就是:如果這個(gè)文件所在的目錄不存在,則創(chuàng)建不了
// 輸出流,會(huì)拋出異常!
// 所以,使用輔助的工具類來(lái)創(chuàng)建一個(gè)文件輸出流:FileUtils.openOutputStream(new
// File(imageLocalFile))
// 通過這個(gè)方法,當(dāng)文件所在的父目錄不存在的時(shí)候,將自動(dòng)創(chuàng)建其所有的父目錄
IOUtils.write(image, FileUtils
.openOutputStream(new File(
imageLocalFile)));
System.out.println("圖片【" + imageUrl
+ "】已下載");
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
applicationContext.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.koyo"/>
</beans>
posted @
2011-12-01 21:01 aya000 閱讀(1071) |
評(píng)論 (0) |
編輯 收藏
public void SetValue(Object obj, String fieldName, Object value)
throws SecurityException, NoSuchFieldException,
NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
String firstLetter = fieldName.substring(0, 1).toUpperCase();
String setMethodName = "set" + firstLetter + fieldName.substring(1);
Field field = obj.getClass().getDeclaredField(fieldName);
Method setMethod = obj.getClass().getDeclaredMethod(setMethodName,
field.getType());
setMethod.invoke(obj, value);
}
posted @
2011-10-16 21:46 aya000 閱讀(1329) |
評(píng)論 (0) |
編輯 收藏
遇到這種問題,請(qǐng)參照這種寫法:
s|Application
{
fontFamily:"Georgia";
color:#000000;
}
問題描述:運(yùn)行flex程序時(shí)彈出錯(cuò)誤 versionNumber must have a non-empty value.
解決辦法:在-app.xml中將<version>修改成<versionNumber>
ok!!!
今天在寫代碼的時(shí)候 想把a(bǔ)ction中的數(shù)據(jù)傳給jsp頁(yè)面中 再將這個(gè)數(shù)據(jù)從jsp頁(yè)面?zhèn)鹘o另一個(gè)action中時(shí)
我想到在jsp頁(yè)面中用<%=request.getAttribute("typeid") %> 具體代碼如下:
<html:link action="/background/expteach/ExpteachManageAction.do?action=expteach&&typeid=
<%=request.getAttribute('typeid') %>" target="rightFrame">返回 </html:link>
但是卻不行,<%=request.getAttribute("typeid") %>取不到值。
于是 我就上網(wǎng)查資料找到了用EL表達(dá)式 具體代碼如下:
<%@ page isELIgnored="false" %>
<html:link action="/background/expteach/ExpteachManageAction.do?action=expteach&&typeid=${typeid}" target="rightFrame">返回 </html:link>
成功!!!
源代碼如下:
<script language="JavaScript">
function submitSearch() {
InvplaForm.action = "InvplaAction.do?action=searchjob";
InvplaForm.submit();
}
</script>
<input id="search_btn" value="搜索" type="button"
onclick="submitSearch();" />
這樣就可以實(shí)現(xiàn)一個(gè)Form里有不同的Acion。
源代碼如下:
<input id="search_btn" value="搜索" type="button"
onclick="location.href='a.jsp'" />
但是不能提交表單!!!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " <html xmlns=" <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無(wú)標(biāo)題文檔</title>
<script type="text/javascript">
var timer;
window.onscroll= function()
{
var oDiv = document.getElementByIdx_x("div1");
//oDiv.style.top = document.body.scrollTop; //不加dtd可以兼容
oDiv.style.top = document.documentElement.scrollTop //加dtd可以兼容
}
</script>
</head>
<body>
<div id="div1" style=" position:absolute; width:100px; height:100px; background:#FF0000"></div>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p><p><textarea rows="15" cols="50" id="text1"></textarea></p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
<p>ssssssssssss</p>
</body>
</html>
FormBean的驗(yàn)證:
1、重寫FormBean的validate方法。
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
ActionErrors errors = new ActionErrors();
if (name == null || name.equals("")) { //nameEmpty為錯(cuò)誤信息名
errors.add("nameEmpty", new ActionMessage("empty.error", "UserName"));
}
if (pwd == null || pwd.equals("")) {
errors.add("pwdEmpty", new ActionMessage("empty.error", "PassWord"));
} //empty.error定義在login.properties文件中,其value值為{0} must not be empty!所以empty.error后面會(huì)有UserName和PassWord。
return errors;
}
2、在struts-config.xml中配置action節(jié)點(diǎn)的validate與input屬性,validate表示是否調(diào)formBean的validate方法,input是如果出錯(cuò)的話跳轉(zhuǎn)的錯(cuò)誤處理界面。注意:如果formBean重寫的了validate方法并且action節(jié)點(diǎn)validate屬性為true,那一定要添加input屬性。
3、在struts-config.xml中添加<message-resources parameter="org.koyo.views.login" />注意:其中的parameter屬性的值是login.properties文件的路徑。(容易被漏掉,多加注意)
4、在界面使用<html:errors />或<html:errors property="nameEmpty"/>顯示錯(cuò)誤信息。
步驟2、3、4,尤其是步驟3,經(jīng)常會(huì)漏掉,應(yīng)多加注意!!!
ActionBean的驗(yàn)證
1、在ActionBean中添加代碼。
ActionMessages messages = new ActionMessages();//不要與FormBean混淆,此處直接就是ActionMessage
messages.add("inputError", new ActionMessage("input.error"));
super.saveErrors(request, messages);//此句容易被漏掉,且常會(huì)被錯(cuò)寫成super.saveMessage(request,messages);
return mapping.getInputForward();
步驟2、3、4,與FormBean驗(yàn)證相同。
主要區(qū)別:ActionBean驗(yàn)證主要做業(yè)務(wù),需要與數(shù)據(jù)庫(kù)交互,比如用戶名是否可用,轉(zhuǎn)賬余額是否可用,出貨余額等驗(yàn)證;formBean雖然完成客戶端驗(yàn)證功能,但需要與服務(wù)器交互。注意不同的區(qū)分標(biāo)準(zhǔn)。。
本文章大部分內(nèi)容轉(zhuǎn)載自 西安云工廠http://www.xaygc.com/struts.html