自拍偷自拍亚洲精品情侣,丁香亚洲综合五月天婷婷,亚洲AV无码国产在丝袜线观看http://www.tkk7.com/zyw090111/category/46088.html我的未來不是夢!zh-cnFri, 22 Nov 2013 20:29:22 GMTFri, 22 Nov 2013 20:29:22 GMT60博客遷移嘍http://www.tkk7.com/zyw090111/archive/2013/10/08/404747.html平常心平常心Tue, 08 Oct 2013 06:02:00 GMThttp://www.tkk7.com/zyw090111/archive/2013/10/08/404747.htmlhttp://www.tkk7.com/zyw090111/comments/404747.htmlhttp://www.tkk7.com/zyw090111/archive/2013/10/08/404747.html#Feedback0http://www.tkk7.com/zyw090111/comments/commentRss/404747.htmlhttp://www.tkk7.com/zyw090111/services/trackbacks/404747.html感謝大家都我博客的關注和關系,現在將博客遷移到www.v5cn.cn上面了,有興趣的童鞋可以到上面尋找自己感興趣的技術博文,主要包括WorldWind,Lucene等技術。www.v5cn.cn



平常心 2013-10-08 14:02 發表評論
]]>
使用Struts2的iterator標簽輕松遍歷復雜的Map類型http://www.tkk7.com/zyw090111/archive/2010/08/26/330017.html平常心平常心Thu, 26 Aug 2010 14:18:00 GMThttp://www.tkk7.com/zyw090111/archive/2010/08/26/330017.htmlhttp://www.tkk7.com/zyw090111/comments/330017.htmlhttp://www.tkk7.com/zyw090111/archive/2010/08/26/330017.html#Feedback0http://www.tkk7.com/zyw090111/comments/commentRss/330017.htmlhttp://www.tkk7.com/zyw090111/services/trackbacks/330017.html更多博客請查看:http://www.v5cn.cn
1.創建一個Web工程,添加Struts2支持。
2.創建兩個實體類:
a). Mother(母親)的Java類。
package struts.map.entity;

import java.io.Serializable;

public class Mother implements Serializable {

private static final long serialVersionUID = 1L;

private int motherId;        //母親ID
    private String motherName;        //母親名字
    public int getMotherId() {
return motherId;
}
public void setMotherId(int motherId) {
this.motherId = motherId;
}
public String getMotherName() {
return motherName;
}
public void setMotherName(String motherName) {
this.motherName = motherName;
}
}

b).Children(孩子)的Java類

package struts.map.entity;

import java.io.Serializable;

public class Children implements Serializable {

private static final long serialVersionUID = 1L;

private int childId;        //孩子ID
    private int motherId;        //母親的ID
    private String childName;        //孩子名字
    
public int getChildId() {
return childId;
}
public void setChildId(int childId) {
this.childId = childId;
}
public int getMotherId() {
return motherId;
}
public void setMotherId(int motherId) {
this.motherId = motherId;
}
public String getChildName() {
return childName;
}
public void setChildName(String childName) {
this.childName = childName;
}
}

 

3. 創建一個Action,并創建一位母親和她的孩子。

package struts.map.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import struts.map.entity.Children;
import struts.map.entity.Mother;

import com.opensymphony.xwork2.ActionSupport;

public class Struts2_Map extends ActionSupport {

private static final long serialVersionUID = 1L;

private Map<Mother,List<Children>> motherChildn;

public Map<Mother, List<Children>> getMotherChildn() {
return motherChildn;
}

@Override
public String execute() throws Exception {
/*-------------------以對象做父節點的鍵,List做子節點的值,的Map-----------------------*/
Mother mother 
= new Mother();
mother.setMotherId(
10000);
mother.setMotherName(
"花木蘭");

Children children1 
= new Children();
children1.setChildId(
10000);
children1.setMotherId(
10000);
children1.setChildName(
"小花木蘭1");

Children children2 
= new Children();
children2.setChildId(
10001);
children2.setMotherId(
10000);
children2.setChildName(
"小花木蘭2");

Children children3 
= new Children();
children3.setChildId(
10002);
children3.setMotherId(
10000);
children3.setChildName(
"小花木蘭3");

motherChildn 
= new HashMap<Mother,List<Children>>();

List
<Children> childrens = new ArrayList<Children>();

childrens.add(children1);
childrens.add(children2);
childrens.add(children3);

motherChildn.put(mother,childrens);

return SUCCESS;
}
}

struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="map" extends="struts-default">
<action name="struts_map" class="struts.map.test.Struts2_Map">
<result>result.jsp</result>
</action>
</package>
</struts>  

4.創建兩個頁面:
a).跳轉頁面:
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Struts_Map</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>
<href="struts_map.action">查看Map</a>
</body>
</html>

b).最終頁面,也是作重要的頁面:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Struts_Map</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>
<div>
<h3>-----------------以對象做父節點的鍵,List做子節點的值,的Map--------------------</h3>
<s:iterator var="mc" value="motherChildn">
<div>
母親名稱:
<s:property value="key.motherName"/>
</div>
<s:iterator var="ch" value="value">
<div>
&nbsp;&nbsp;&nbsp;孩子名稱:<s:property value="#ch.childName"/>
</div>
</s:iterator>
</s:iterator>
</div>
</body>
</html>

最終運行結果:


平常心 2010-08-26 22:18 發表評論
]]>
使用Struts2+Gson+JQuery實現異步請求JSON對象http://www.tkk7.com/zyw090111/archive/2010/07/29/327501.html平常心平常心Thu, 29 Jul 2010 10:15:00 GMThttp://www.tkk7.com/zyw090111/archive/2010/07/29/327501.htmlhttp://www.tkk7.com/zyw090111/comments/327501.htmlhttp://www.tkk7.com/zyw090111/archive/2010/07/29/327501.html#Feedback0http://www.tkk7.com/zyw090111/comments/commentRss/327501.htmlhttp://www.tkk7.com/zyw090111/services/trackbacks/327501.html更多博客請查看:http://www.v5cn.cn
GSON是Google公司的Java對象序列化成JSON的插件
下載地址:http://code.google.com/p/google-gson/downloads/list
下載下來以后:把gson-1.4.jar這個jar文件加到工程里。
Action的使用方式是:
package test.gson;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.google.gson.Gson;
import com.opensymphony.xwork2.ActionSupport;

public class TestGson extends ActionSupport {
    
private static final long serialVersionUID = 1L;
    
private Users user;
    
public Users getUser() {
        
return user;
    }

    
public void setUser(Users user) {
        
this.user = user;
    }

    @Override
    
public String execute() throws Exception {
        user 
= new Users();
        user.setId(
10000);
        user.setUserName(
"zhangsan");
        user.setPwd(
"000000");
        user.setEmail(
"zhangsan@sina.com");
        
        Gson g  
= new Gson();
        String json 
= g.toJson(user);
        HttpServletResponse response 
= ServletActionContext.getResponse();
        response.setContentType(
"application/json;charset=utf-8");
        response.setHeader(
"Cache-Control","no-cache");
        
        PrintWriter pw 
= response.getWriter();
        pw.print(json);
        pw.flush();
        pw.close();
        
        
        
return null;
    }

}

其中response.setContentType("application/json;charset=utf-8");是最重要的
一定要把ContentType設置成application/json形式
struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    
<package name="jsons" extends="struts-default" namespace="/">
        
<action name="testGson" class="test.gson.TestGson"></action>
    
</package>
</struts>
Gson其實可以用在所有的Javaweb工程了,不一定是Struts2

平常心 2010-07-29 18:15 發表評論
]]>
Struts2+JSON+jQuery實現異步交互數據時選擇要序列化的屬性(二使用XML配置方式)http://www.tkk7.com/zyw090111/archive/2010/07/29/327456.html平常心平常心Thu, 29 Jul 2010 08:29:00 GMThttp://www.tkk7.com/zyw090111/archive/2010/07/29/327456.htmlhttp://www.tkk7.com/zyw090111/comments/327456.htmlhttp://www.tkk7.com/zyw090111/archive/2010/07/29/327456.html#Feedback1http://www.tkk7.com/zyw090111/comments/commentRss/327456.htmlhttp://www.tkk7.com/zyw090111/services/trackbacks/327456.html更多博客請查看:http://www.v5cn.cn
只需在XML配置就可以了,配置方式是:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    
<package name="jsons" extends="json-default" namespace="/">
        
<action name="getJSON" class="test.json.Users">
            
<result name="success" type="json">
                
<!-- excludeProperties表示不包含的屬性(可以使用正則表達式匹配) -->
                
<param name="excludeProperties">
                    id,userName
                
</param>
                
<!-- includeProperties表示包含序列化的屬性(可以使用正則表達式匹配) -->
                
<param name="includeProperties">
                    pwd,address
                
</param>
            
</result>
        
</action>
    
</package>
</struts>    
默認情況下Struts2插件的序列化是從Action開始的如果需要序列化從指定的方式開始請使用:
<!-- 這樣序列化工作就從birthday開始了 -->
                
<param name="root">
                    birthday
                
</param>
Struts2JSONPlugin使用文檔.pdf

平常心 2010-07-29 16:29 發表評論
]]>
Struts2+JSON+jQuery實現異步交互數據時選擇要序列化的屬性(一注解方式)http://www.tkk7.com/zyw090111/archive/2010/07/29/327452.html平常心平常心Thu, 29 Jul 2010 08:15:00 GMThttp://www.tkk7.com/zyw090111/archive/2010/07/29/327452.htmlhttp://www.tkk7.com/zyw090111/comments/327452.htmlhttp://www.tkk7.com/zyw090111/archive/2010/07/29/327452.html#Feedback2http://www.tkk7.com/zyw090111/comments/commentRss/327452.htmlhttp://www.tkk7.com/zyw090111/services/trackbacks/327452.html更多博客請查看:http://www.v5cn.cn
在使用Struts2的JSON插件,實現Action中的屬性序列化成JSON對象時默認JSON插件會把所有Action中包含getter方法的屬性都序列化到JSON對象中。但是有時候我們并不需要太多的屬性,或者只需要一個屬性。那么怎樣控制屬性序列化到JSON對象中哪?Struts2的JSON插件為我們提供了兩種方式,第一:使用注解的方式控制,第二:使用Struts2的struts.xml配置文件的方式。

這一講我們主要介紹注解方式。如果大家還不會Struts2+JSON+JQuery的交互方式請查看 http://zyw090111.javaeye.comStruts2+jQuery+JSON實現異步交互的文章

我們要使用JSON的注解是@JSON這個類共有是個屬性分別是:
1. name    String 類型     用戶為屬性起一個別名(我們序列化到JSON對象中的鍵默認是屬性名稱,如果使用了name屬性那么鍵是name起的名字);
2. serialize  Boolean類型   默認為true 也就是可以被序列化,如果設為false那么該屬性將不包含在JSON對象中;
3. format  String類型  主要是對日期進行格式化
4. deserialize Boolean類型 默認為true,它是指反序列化,和serialize相反。
請看代碼:
package test.json;

import java.util.Date;

import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings(
"serial")
public class Users extends ActionSupport {
    
private int id;
    
private String userName;
    
private String pwd;
    
private String address;
    
private Date birthday;
    
public int getId() {
        
return id;
    }

    
public void setId(int id) {
        
this.id = id;
    }

    @JSON(serialize
=false)
    
public String getUserName() {
        
return userName;
    }

    
    
public void setUserName(String userName) {
        
this.userName = userName;
    }

    @JSON(name
="mm")
    
public String getPwd() {
        
return pwd;
    }

    
public void setPwd(String pwd) {
        
this.pwd = pwd;
    }

    
public String getAddress() {
        
return address;
    }

    
public void setAddress(String address) {
        
this.address = address;
    }

    @JSON(format
="yy-MM-dd")
    
public Date getBirthday() {
        
return birthday;
    }

    
public void setBirthday(Date birthday) {
        
this.birthday = birthday;
    }

    @Override
    
public String execute() throws Exception {
        
        
this.id = 10000;
        
this.userName = "zhangsan";
        
this.pwd = "00000";
        
this.address = "xian";
        
this.birthday = new Date();
        
        
return SUCCESS;
    }

}


平常心 2010-07-29 16:15 發表評論
]]>
主站蜘蛛池模板: 国产亚洲一卡2卡3卡4卡新区| 亚洲高清一区二区三区| 久久精品无码专区免费| 中文字幕第一页亚洲| 特级毛片免费观看视频| 国产精品亚洲产品一区二区三区| 国产精品免费视频观看拍拍| 亚洲中文字幕无码爆乳AV| 最近中文字幕大全免费版在线| 亚洲AV无码一区二区乱子伦| 中文字幕天天躁日日躁狠狠躁免费 | 亚洲中文字幕在线无码一区二区| 精品免费久久久久久久| 亚洲乱码日产精品BD在线观看| 18禁无遮挡无码网站免费| 精品亚洲成a人在线观看| 亚洲欧洲精品成人久久奇米网| 国产一级黄片儿免费看| 亚洲AV人无码综合在线观看| 四虎1515hh永久久免费| 亚洲欧美日韩中文高清www777| 免费真实播放国产乱子伦| 香蕉免费看一区二区三区| 亚洲一区二区电影| 女人18特级一级毛片免费视频| 亚洲阿v天堂在线2017免费| 亚洲人成影院在线| 国产精品深夜福利免费观看| 精品国产污污免费网站入口| 久久亚洲AV成人无码| 在线精品免费视频| 91成人免费观看在线观看| 激情亚洲一区国产精品| 一级毛片直播亚洲| 亚洲成年人免费网站| 偷自拍亚洲视频在线观看99| 亚洲成A人片在线观看WWW| 麻豆精品国产免费观看| 国产精品99精品久久免费| 久久精品国产亚洲AV未满十八| 久久久久久久久亚洲|