posts - 15,comments - 0,trackbacks - 0
这里所说的不是驱动对象,而是这个内核模块在内核内存空间中的地址。这是一个常用的技巧:在驱动对象中DriverStart域和DriverSize域分别记载着这个驱动对象所代表的内核模块在内核空间中的开始地址和大小。
posted @ 2012-11-12 19:06 aya000 阅读(206) | 评论 (0)编辑 收藏
error LNK2019: unresolved external symbol _RtlStringVPrintfWorkerW@20 referenced in function _RtlStringCchPrintfW
error LNK2019: unresolved external symbol _RtlStringValidateDestW@12 referenced in function _RtlStringCchPrintfW
sources文件加入库文件
TARGETLIBS= $(DDK_LIB_PATH)\ntstrsafe.lib
原文:http://blog.csdn.net/iamoyjj/archive/2011/02/01/6171792.aspx
posted @ 2012-11-11 17:30 aya000 阅读(647) | 评论 (0)编辑 收藏
1>避免创建不必要的对象
2>如果方法用不到成员变量,可以把方法声明为static,性能会提高15%到20%
3>避免使用getters/setters存取Field,可以把Field声明为public,直接访问
4>static的变量如果不需要修改,应使用static final 修饰符定义为常量
5>使用增强for循环语法——for(:)
6>私有内布类要访问外部类的Field或方法,可以把外部类的Field或方法声明为包访问权限
7>合理使用浮点数,浮点数比整型慢两倍
posted @ 2012-11-03 22:30 aya000 阅读(228) | 评论 (0)编辑 收藏
这大概是由xml文件中的编码规则决定要这么变换。
在xml文件中有以下几类字符要进行转义替换:

<

<

小于号

&gt;

>

大于号

&amp;

&

&apos;

'

单引号

&quot;

"

双引号


posted @ 2012-10-28 00:11 aya000 阅读(423) | 评论 (0)编辑 收藏
(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]-->
posted @ 2012-08-16 15:03 aya000 阅读(188) | 评论 (0)编辑 收藏
        .
        .
        .
         //改变状态
        this.addEventListener(MouseEvent.DOUBLE_CLICK,changeImg);
        .   
        .
        .
//改变
public function changeImg():void {
    arguments; //如果方法没有参数,则必须在方法中添加这个声明
    if(this.source == img0) {
        this.source = img1;
    } else {
            this.source = img0;
      }
        }
posted @ 2012-04-15 12:20 aya000 阅读(1441) | 评论 (0)编辑 收藏
  请求登录人人网比较麻烦,需要记住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 = "http://photo.renren.com/photo/" + friendId
     + "/album/relatives";

   // ===================请求登录======================================================
   HttpPost post = new HttpPost("http://www.renren.com/PLogin.do");
   // 添加POST参数
   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();
    // 使用响应中的编码来解释响应的内容
    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("账号:" + loginName);
    System.out.println("密码:" + loginPassword);
   }
   // ===================获取相册页面信息===================================================
   // 根据URL地址,获取网页内容
   String html = HttpUtils.getHtml(httpClient, httpContext, url);

   if (html == null) {
    logger.error("无法获取【" + url + "】网址的内容");
    throw new RuntimeException("无法获取【" + url + "】网址的内容");
   }
   
   //获取好友名
   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();
   
   //获取相册名
   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();
     //由于头像相册前还有一个<span class="userhead"/>  故不能使用tempName.trim()
     albumName = tempName.substring(tempName.lastIndexOf("\n")+1);
     url = linkTags.get(i).getLink();
     // 根据URL地址,获取网页内容
     html = HttpUtils.getHtml(httpClient, httpContext, url);

     if (html == null) {
      logger.error("无法获取【" + url + "】网址的内容");
      throw new RuntimeException("无法获取【" + url + "】网址的内容");
     }

     List<LinkTag> linkTags2 = ParseUtils.parseTags(html,
       LinkTag.class, "class", "picture");
     if (linkTags2 != null) {
      for (LinkTag linkTag2 : linkTags2) {
       url = linkTag2.getLink();
       // 根据URL地址,获取网页内容
       html = HttpUtils.getHtml(httpClient, httpContext,
         url);

       if (html == null) {
        logger.error("无法获取【" + url + "】网址的内容");
        throw new RuntimeException("无法获取【" + url
          + "】网址的内容");
       }

       // 网页中所包含的图片,并下载到upload目录,然后创建Attachment对象
       ImageTag imageTag = ParseUtils.parseTag(html,
         ImageTag.class, "id", "photo");
       if (imageTag != null) {

        // 得到图片所在的路径目录
        // String baseUrl = url.substring(0,
        // url.lastIndexOf("/") + 1);

        // 这个是<img>标签中的src的值
        String imageUrl = imageTag.getImageURL();
        String photoName = imageUrl.substring(imageUrl
          .lastIndexOf("/"));
        // 图片的绝对路径
        // String absoluteUrl = baseUrl + imageUrl;

        // : "文章标题/xxx.jpg"
        String imageName = friendName + "/" +albumName + photoName;

        // 把图片保存到upload目录
        // 首先确定,保存到本地的图片的路径
        String imageLocalFile = "D:/PhotosForRenRen/"
          + imageName;

        // 如果图片已经被下载到本地,则不再下载
        if (!new File(imageLocalFile).exists()) {
         // 下载图片的信息
         byte[] image = HttpUtils.getImage(
           httpClient, httpContext, imageUrl);
         // 直接使用new
         // FileOutputStream(imageLocalFile)这种方式,创建一个
         // 文件输出流,存在的问题就是:如果这个文件所在的目录不存在,则创建不了
         // 输出流,会抛出异常!
         // 所以,使用辅助的工具类来创建一个文件输出流:FileUtils.openOutputStream(new
         // File(imageLocalFile))
         // 通过这个方法,当文件所在的父目录不存在的时候,将自动创建其所有的父目录
         IOUtils.write(image, FileUtils
           .openOutputStream(new File(
             imageLocalFile)));
         System.out.println("图片【" + imageUrl
           + "】已下载");
        }
       }
      }
     }
    }
   }

  } catch (Exception e) {
   e.printStackTrace();
  }

 }
}

posted @ 2012-02-23 13:42 aya000 阅读(472) | 评论 (0)编辑 收藏
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 阅读(1053) | 评论 (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 阅读(1300) | 评论 (0)编辑 收藏
遇到这种问题,请参照这种写法:
s|Application
{               
    fontFamily:"Georgia";
    color:#000000;
}
posted @ 2011-08-30 16:42 aya000 阅读(720) | 评论 (0)编辑 收藏
问题描述:运行flex程序时弹出错误  versionNumber must have a non-empty value.
解决办法:在-app.xml中将<version>修改成<versionNumber>
ok!!!
posted @ 2011-08-02 15:56 aya000 阅读(356) | 评论 (0)编辑 收藏
今天在写代码的时候   想把action中的数据传给jsp页面中  再将这个数据从jsp页面传给另一个action中时 
我想到在jsp页面中用<%=request.getAttribute("typeid") %>  具体代码如下:

<html:link action="/background/expteach/ExpteachManageAction.do?action=expteach&&typeid=<%=request.getAttribute('typeid') %>" target="rightFrame">返回 </html:link>

但是却不行,<%=request.getAttribute("typeid") %>取不到值。
于是  我就上网查资料找到了用EL表达式  具体代码如下:

<%@ page isELIgnored="false" %>
<html:link action="/background/expteach/ExpteachManageAction.do?action=expteach&&typeid=${typeid}" target="rightFrame">返回 </html:link>
成功!!!
posted @ 2011-07-15 22:50 aya000 阅读(101) | 评论 (0)编辑 收藏
源代码如下:
<script language="JavaScript">

function submitSearch() {
    InvplaForm.action = "InvplaAction.do?action=searchjob";
    InvplaForm.submit();

}
</script>

<input id="search_btn" value="搜索" type="button"
                                            onclick="submitSearch();" />

这样就可以实现一个Form里有不同的Acion。
posted @ 2011-06-08 10:21 aya000 阅读(285) | 评论 (0)编辑 收藏
源代码如下:
<input id="search_btn" value="搜索" type="button"
                                            onclick="location.href='a.jsp'" />
但是不能提交表单!!!!
posted @ 2011-06-07 15:44 aya000 阅读(80) | 评论 (0)编辑 收藏

<!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>无标题文档</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>

posted @ 2011-06-03 21:44 aya000 阅读(150) | 评论 (0)编辑 收藏

FormBean的验证:

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为错误信息名
   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后面会有UserName和PassWord。
  return errors;
 }
2、在struts-config.xml中配置action节点的validate与input属性,validate表示是否调formBean的validate方法,input是如果出错的话跳转的错误处理界面。注意:如果formBean重写的了validate方法并且action节点validate属性为true,那一定要添加input属性。  

3、在struts-config.xml中添加<message-resources parameter="org.koyo.views.login" />注意:其中的parameter属性的值是login.properties文件的路径。(容易被漏掉,多加注意)

4、在界面使用<html:errors />或<html:errors property="nameEmpty"/>显示错误信息。

步骤2、3、4,尤其是步骤3,经常会漏掉,应多加注意!!!

ActionBean的验证

1、在ActionBean中添加代码。

ActionMessages messages = new ActionMessages();//不要与FormBean混淆,此处直接就是ActionMessage
   messages.add("inputError", new ActionMessage("input.error"));
   super.saveErrors(request, messages);//此句容易被漏掉,且常会被错写成super.saveMessage(request,messages);
   return mapping.getInputForward();

步骤2、3、4,与FormBean验证相同。

主要区别:ActionBean验证主要做业务,需要与数据库交互,比如用户名是否可用,转账余额是否可用,出货余额等验证;formBean虽然完成客户端验证功能,但需要与服务器交互。注意不同的区分标准。。

 

本文章大部分内容转载自 西安云工厂http://www.xaygc.com/struts.html

posted @ 2011-06-03 21:43 aya000 阅读(245) | 评论 (0)编辑 收藏